]> git.saurik.com Git - apple/cf.git/blob - ForFoundationOnly.h
CF-550.13.tar.gz
[apple/cf.git] / ForFoundationOnly.h
1 /*
2 * Copyright (c) 2009 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 /* ForFoundationOnly.h
25 Copyright (c) 1998-2009, Apple Inc. All rights reserved.
26 */
27
28 #if !CF_BUILDING_CF && !NSBUILDINGFOUNDATION
29 #error The header file ForFoundationOnly.h is for the exclusive use of the
30 #error CoreFoundation and Foundation projects. No other project should include it.
31 #endif
32
33 #if !defined(__COREFOUNDATION_FORFOUNDATIONONLY__)
34 #define __COREFOUNDATION_FORFOUNDATIONONLY__ 1
35
36 #include <CoreFoundation/CFBase.h>
37 #include <CoreFoundation/CFString.h>
38 #include <CoreFoundation/CFArray.h>
39 #include <CoreFoundation/CFData.h>
40 #include <CoreFoundation/CFDictionary.h>
41 #include <CoreFoundation/CFSet.h>
42 #include <CoreFoundation/CFPriv.h>
43 #include <CoreFoundation/CFPropertyList.h>
44 #include <CoreFoundation/CFError.h>
45 #include <CoreFoundation/CFStringEncodingExt.h>
46 #include <limits.h>
47
48 // NOTE: miscellaneous declarations are at the end
49
50 // ---- CFRuntime material ----------------------------------------
51
52 CF_EXTERN_C_BEGIN
53
54 #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED
55 #include <malloc/malloc.h>
56 #endif
57
58 CF_EXTERN_C_END
59
60 // ---- CFBundle material ----------------------------------------
61
62 #include <CoreFoundation/CFBundlePriv.h>
63
64 CF_EXTERN_C_BEGIN
65
66 CF_EXPORT const CFStringRef _kCFBundleExecutablePathKey;
67 CF_EXPORT const CFStringRef _kCFBundleInfoPlistURLKey;
68 CF_EXPORT const CFStringRef _kCFBundleRawInfoPlistURLKey;
69 CF_EXPORT const CFStringRef _kCFBundleNumericVersionKey;
70 CF_EXPORT const CFStringRef _kCFBundleResourcesFileMappedKey;
71 CF_EXPORT const CFStringRef _kCFBundleCFMLoadAsBundleKey;
72 CF_EXPORT const CFStringRef _kCFBundleAllowMixedLocalizationsKey;
73 CF_EXPORT const CFStringRef _kCFBundleInitialPathKey;
74 CF_EXPORT const CFStringRef _kCFBundleResolvedPathKey;
75 CF_EXPORT const CFStringRef _kCFBundlePrincipalClassKey;
76
77 CF_EXPORT CFArrayRef _CFFindBundleResources(CFBundleRef bundle, CFURLRef bundleURL, CFStringRef subDirName, CFArrayRef searchLanguages, CFStringRef resName, CFArrayRef resTypes, CFIndex limit, UInt8 version);
78
79 CF_EXPORT UInt8 _CFBundleLayoutVersion(CFBundleRef bundle);
80
81 CF_EXPORT CFArrayRef _CFBundleCopyLanguageSearchListInDirectory(CFAllocatorRef alloc, CFURLRef url, UInt8 *version);
82 CF_EXPORT CFArrayRef _CFBundleGetLanguageSearchList(CFBundleRef bundle);
83
84 CF_EXPORT Boolean _CFBundleLoadExecutableAndReturnError(CFBundleRef bundle, Boolean forceGlobal, CFErrorRef *error);
85 CF_EXPORT CFErrorRef _CFBundleCreateError(CFAllocatorRef allocator, CFBundleRef bundle, CFIndex code);
86
87 CF_EXTERN_C_END
88
89
90 // ---- CFPreferences material ----------------------------------------
91
92 #define DEBUG_PREFERENCES_MEMORY 0
93
94 #if DEBUG_PREFERENCES_MEMORY
95 #include "../Tests/CFCountingAllocator.h"
96 #endif
97
98 CF_EXTERN_C_BEGIN
99
100 extern void _CFPreferencesPurgeDomainCache(void);
101
102 typedef struct {
103 void * (*createDomain)(CFAllocatorRef allocator, CFTypeRef context);
104 void (*freeDomain)(CFAllocatorRef allocator, CFTypeRef context, void *domain);
105 CFTypeRef (*fetchValue)(CFTypeRef context, void *domain, CFStringRef key); // Caller releases
106 void (*writeValue)(CFTypeRef context, void *domain, CFStringRef key, CFTypeRef value);
107 Boolean (*synchronize)(CFTypeRef context, void *domain);
108 void (*getKeysAndValues)(CFAllocatorRef alloc, CFTypeRef context, void *domain, void **buf[], CFIndex *numKeyValuePairs);
109 CFDictionaryRef (*copyDomainDictionary)(CFTypeRef context, void *domain);
110 /* HACK - see comment on _CFPreferencesDomainSetIsWorldReadable(), below */
111 void (*setIsWorldReadable)(CFTypeRef context, void *domain, Boolean isWorldReadable);
112 } _CFPreferencesDomainCallBacks;
113
114 CF_EXPORT CFAllocatorRef __CFPreferencesAllocator(void);
115 CF_EXPORT const _CFPreferencesDomainCallBacks __kCFVolatileDomainCallBacks;
116 CF_EXPORT const _CFPreferencesDomainCallBacks __kCFXMLPropertyListDomainCallBacks;
117
118 typedef struct __CFPreferencesDomain * CFPreferencesDomainRef;
119
120 CF_EXPORT CFPreferencesDomainRef _CFPreferencesDomainCreate(CFTypeRef context, const _CFPreferencesDomainCallBacks *callBacks);
121 CF_EXPORT CFPreferencesDomainRef _CFPreferencesStandardDomain(CFStringRef domainName, CFStringRef userName, CFStringRef hostName);
122
123 CF_EXPORT CFTypeRef _CFPreferencesDomainCreateValueForKey(CFPreferencesDomainRef domain, CFStringRef key);
124 CF_EXPORT void _CFPreferencesDomainSet(CFPreferencesDomainRef domain, CFStringRef key, CFTypeRef value);
125 CF_EXPORT Boolean _CFPreferencesDomainSynchronize(CFPreferencesDomainRef domain);
126
127 CF_EXPORT CFArrayRef _CFPreferencesCreateDomainList(CFStringRef userName, CFStringRef hostName);
128 CF_EXPORT Boolean _CFSynchronizeDomainCache(void);
129
130 CF_EXPORT void _CFPreferencesDomainSetDictionary(CFPreferencesDomainRef domain, CFDictionaryRef dict);
131 CF_EXPORT CFDictionaryRef _CFPreferencesDomainDeepCopyDictionary(CFPreferencesDomainRef domain);
132 CF_EXPORT Boolean _CFPreferencesDomainExists(CFStringRef domainName, CFStringRef userName, CFStringRef hostName);
133
134 /* 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 */
135 CF_EXPORT void _CFPreferencesDomainSetIsWorldReadable(CFPreferencesDomainRef domain, Boolean isWorldReadable);
136
137 typedef struct {
138 CFMutableArrayRef _search; // the search list; an array of _CFPreferencesDomains
139 CFMutableDictionaryRef _dictRep; // Mutable; a collapsed view of the search list, expressed as a single dictionary
140 CFStringRef _appName;
141 } _CFApplicationPreferences;
142
143 CF_EXPORT _CFApplicationPreferences *_CFStandardApplicationPreferences(CFStringRef appName);
144 CF_EXPORT _CFApplicationPreferences *_CFApplicationPreferencesCreateWithUser(CFStringRef userName, CFStringRef appName);
145 CF_EXPORT void _CFDeallocateApplicationPreferences(_CFApplicationPreferences *self);
146 CF_EXPORT CFTypeRef _CFApplicationPreferencesCreateValueForKey(_CFApplicationPreferences *prefs, CFStringRef key);
147 CF_EXPORT void _CFApplicationPreferencesSet(_CFApplicationPreferences *self, CFStringRef defaultName, CFTypeRef value);
148 CF_EXPORT void _CFApplicationPreferencesRemove(_CFApplicationPreferences *self, CFStringRef defaultName);
149 CF_EXPORT Boolean _CFApplicationPreferencesSynchronize(_CFApplicationPreferences *self);
150 CF_EXPORT void _CFApplicationPreferencesUpdate(_CFApplicationPreferences *self); // same as updateDictRep
151 CF_EXPORT CFDictionaryRef _CFApplicationPreferencesCopyRepresentation3(_CFApplicationPreferences *self, CFDictionaryRef hint, CFDictionaryRef insertion, CFPreferencesDomainRef afterDomain);
152 CF_EXPORT CFDictionaryRef _CFApplicationPreferencesCopyRepresentationWithHint(_CFApplicationPreferences *self, CFDictionaryRef hint); // same as dictRep
153 CF_EXPORT void _CFApplicationPreferencesSetStandardSearchList(_CFApplicationPreferences *appPreferences);
154 CF_EXPORT void _CFApplicationPreferencesSetCacheForApp(_CFApplicationPreferences *appPrefs, CFStringRef appName);
155 CF_EXPORT void _CFApplicationPreferencesAddSuitePreferences(_CFApplicationPreferences *appPrefs, CFStringRef suiteName);
156 CF_EXPORT void _CFApplicationPreferencesRemoveSuitePreferences(_CFApplicationPreferences *appPrefs, CFStringRef suiteName);
157
158 CF_EXPORT void _CFApplicationPreferencesAddDomain(_CFApplicationPreferences *self, CFPreferencesDomainRef domain, Boolean addAtTop);
159 CF_EXPORT Boolean _CFApplicationPreferencesContainsDomain(_CFApplicationPreferences *self, CFPreferencesDomainRef domain);
160 CF_EXPORT void _CFApplicationPreferencesRemoveDomain(_CFApplicationPreferences *self, CFPreferencesDomainRef domain);
161
162 CF_EXPORT CFTypeRef _CFApplicationPreferencesSearchDownToDomain(_CFApplicationPreferences *self, CFPreferencesDomainRef stopper, CFStringRef key);
163
164
165 CF_EXTERN_C_END
166
167
168
169 // ---- CFString material ----------------------------------------
170
171 #include <CoreFoundation/CFStringEncodingExt.h>
172
173 CF_EXTERN_C_BEGIN
174
175 /* Create a byte stream from a CFString backing. Can convert a string piece at a
176 time into a fixed size buffer. Returns number of characters converted.
177 Characters that cannot be converted to the specified encoding are represented
178 with the char specified by lossByte; if 0, then lossy conversion is not allowed
179 and conversion stops, returning partial results.
180 generatingExternalFile indicates that any extra stuff to allow this data to be
181 persistent (for instance, BOM) should be included.
182 Pass buffer==NULL if you don't care about the converted string (but just the
183 convertability, or number of bytes required, indicated by usedBufLen).
184 Does not zero-terminate. If you want to create Pascal or C string, allow one
185 extra byte at start or end.
186 */
187 CF_EXPORT CFIndex __CFStringEncodeByteStream(CFStringRef string, CFIndex rangeLoc, CFIndex rangeLen, Boolean generatingExternalFile, CFStringEncoding encoding, char lossByte, UInt8 *buffer, CFIndex max, CFIndex *usedBufLen);
188
189 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);
190
191 CF_INLINE Boolean __CFStringEncodingIsSupersetOfASCII(CFStringEncoding encoding) {
192 switch (encoding & 0x0000FF00) {
193 case 0x0: // MacOS Script range
194 // Symbol & bidi encodings are not ASCII superset
195 if (encoding == kCFStringEncodingMacJapanese || encoding == kCFStringEncodingMacArabic || encoding == kCFStringEncodingMacHebrew || encoding == kCFStringEncodingMacUkrainian || encoding == kCFStringEncodingMacSymbol || encoding == kCFStringEncodingMacDingbats) return false;
196 return true;
197
198 case 0x100: // Unicode range
199 if (encoding != kCFStringEncodingUTF8) return false;
200 return true;
201
202 case 0x200: // ISO range
203 if (encoding == kCFStringEncodingISOLatinArabic) return false;
204 return true;
205
206 case 0x600: // National standards range
207 if (encoding != kCFStringEncodingASCII) return false;
208 return true;
209
210 case 0x800: // ISO 2022 range
211 return false; // It's modal encoding
212
213 case 0xA00: // Misc standard range
214 if ((encoding == kCFStringEncodingShiftJIS) || (encoding == kCFStringEncodingHZ_GB_2312)) return false;
215 return true;
216
217 case 0xB00:
218 if (encoding == kCFStringEncodingNonLossyASCII) return false;
219 return true;
220
221 case 0xC00: // EBCDIC
222 return false;
223
224 default:
225 return ((encoding & 0x0000FF00) > 0x0C00 ? false : true);
226 }
227 }
228
229
230 /* Desperately using extern here */
231 CF_EXPORT CFStringEncoding __CFDefaultEightBitStringEncoding;
232 CF_EXPORT CFStringEncoding __CFStringComputeEightBitStringEncoding(void);
233
234 CF_INLINE CFStringEncoding __CFStringGetEightBitStringEncoding(void) {
235 if (__CFDefaultEightBitStringEncoding == kCFStringEncodingInvalidId) __CFStringComputeEightBitStringEncoding();
236 return __CFDefaultEightBitStringEncoding;
237 }
238
239 enum {
240 __kCFVarWidthLocalBufferSize = 1008
241 };
242
243 typedef struct { /* A simple struct to maintain ASCII/Unicode versions of the same buffer. */
244 union {
245 UInt8 *ascii;
246 UniChar *unicode;
247 } chars;
248 Boolean isASCII; /* This really does mean 7-bit ASCII, not _NSDefaultCStringEncoding() */
249 Boolean shouldFreeChars; /* If the number of bytes exceeds __kCFVarWidthLocalBufferSize, bytes are allocated */
250 Boolean _unused1;
251 Boolean _unused2;
252 CFAllocatorRef allocator; /* Use this allocator to allocate, reallocate, and deallocate the bytes */
253 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 */
254 UInt8 localBuffer[__kCFVarWidthLocalBufferSize]; /* private; 168 ISO2022JP chars, 504 Unicode chars, 1008 ASCII chars */
255 } CFVarWidthCharBuffer;
256
257
258 /* 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.
259 !!! 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.
260 !!! __CFStringDecodeByteStream2() needs to be deprecated and removed post-Jaguar.
261 */
262 CF_EXPORT Boolean __CFStringDecodeByteStream2(const UInt8 *bytes, UInt32 len, CFStringEncoding encoding, Boolean alwaysUnicode, CFVarWidthCharBuffer *buffer, Boolean *useClientsMemoryPtr);
263 CF_EXPORT Boolean __CFStringDecodeByteStream3(const UInt8 *bytes, CFIndex len, CFStringEncoding encoding, Boolean alwaysUnicode, CFVarWidthCharBuffer *buffer, Boolean *useClientsMemoryPtr, UInt32 converterFlags);
264
265
266 /* 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.
267 */
268 CF_EXPORT Boolean (*__CFCharToUniCharFunc)(UInt32 flags, UInt8 ch, UniChar *unicodeChar);
269
270 /* Character class functions UnicodeData-2_1_5.txt
271 */
272 CF_INLINE Boolean __CFIsWhitespace(UniChar theChar) {
273 return ((theChar < 0x21) || (theChar > 0x7E && theChar < 0xA1) || (theChar >= 0x2000 && theChar <= 0x200B) || (theChar == 0x3000)) ? true : false;
274 }
275
276 /* Same as CFStringGetCharacterFromInlineBuffer() but returns 0xFFFF on out of bounds access
277 */
278 CF_INLINE UniChar __CFStringGetCharacterFromInlineBufferAux(CFStringInlineBuffer *buf, CFIndex idx) {
279 if (buf->directBuffer) {
280 if (idx < 0 || idx >= buf->rangeToBuffer.length) return 0xFFFF;
281 return buf->directBuffer[idx + buf->rangeToBuffer.location];
282 }
283 if (idx >= buf->bufferedRangeEnd || idx < buf->bufferedRangeStart) {
284 if (idx < 0 || idx >= buf->rangeToBuffer.length) return 0xFFFF;
285 if ((buf->bufferedRangeStart = idx - 4) < 0) buf->bufferedRangeStart = 0;
286 buf->bufferedRangeEnd = buf->bufferedRangeStart + __kCFStringInlineBufferLength;
287 if (buf->bufferedRangeEnd > buf->rangeToBuffer.length) buf->bufferedRangeEnd = buf->rangeToBuffer.length;
288 CFStringGetCharacters(buf->theString, CFRangeMake(buf->rangeToBuffer.location + buf->bufferedRangeStart, buf->bufferedRangeEnd - buf->bufferedRangeStart), buf->buffer);
289 }
290 return buf->buffer[idx - buf->bufferedRangeStart];
291 }
292
293 /* Same as CFStringGetCharacterFromInlineBuffer(), but without the bounds checking (will return garbage or crash)
294 */
295 CF_INLINE UniChar __CFStringGetCharacterFromInlineBufferQuick(CFStringInlineBuffer *buf, CFIndex idx) {
296 if (buf->directBuffer) return buf->directBuffer[idx + buf->rangeToBuffer.location];
297 if (idx >= buf->bufferedRangeEnd || idx < buf->bufferedRangeStart) {
298 if ((buf->bufferedRangeStart = idx - 4) < 0) buf->bufferedRangeStart = 0;
299 buf->bufferedRangeEnd = buf->bufferedRangeStart + __kCFStringInlineBufferLength;
300 if (buf->bufferedRangeEnd > buf->rangeToBuffer.length) buf->bufferedRangeEnd = buf->rangeToBuffer.length;
301 CFStringGetCharacters(buf->theString, CFRangeMake(buf->rangeToBuffer.location + buf->bufferedRangeStart, buf->bufferedRangeEnd - buf->bufferedRangeStart), buf->buffer);
302 }
303 return buf->buffer[idx - buf->bufferedRangeStart];
304 }
305
306
307 /* These two allow specifying an alternate description function (instead of CFCopyDescription); used by NSString
308 */
309 CF_EXPORT void _CFStringAppendFormatAndArgumentsAux(CFMutableStringRef outputString, CFStringRef (*copyDescFunc)(void *, const void *loc), CFDictionaryRef formatOptions, CFStringRef formatString, va_list args);
310 CF_EXPORT CFStringRef _CFStringCreateWithFormatAndArgumentsAux(CFAllocatorRef alloc, CFStringRef (*copyDescFunc)(void *, const void *loc), CFDictionaryRef formatOptions, CFStringRef format, va_list arguments);
311
312 /* For NSString (and NSAttributedString) usage, mutate with isMutable check
313 */
314 enum {_CFStringErrNone = 0, _CFStringErrNotMutable = 1, _CFStringErrNilArg = 2, _CFStringErrBounds = 3};
315 CF_EXPORT int __CFStringCheckAndReplace(CFMutableStringRef str, CFRange range, CFStringRef replacement);
316 CF_EXPORT Boolean __CFStringNoteErrors(void); // Should string errors raise?
317
318 /* For NSString usage, guarantees that the contents can be extracted as 8-bit bytes in the __CFStringGetEightBitStringEncoding().
319 */
320 CF_EXPORT Boolean __CFStringIsEightBit(CFStringRef str);
321
322 /* For NSCFString usage, these do range check (where applicable) but don't check for ObjC dispatch
323 */
324 CF_EXPORT int _CFStringCheckAndGetCharacterAtIndex(CFStringRef str, CFIndex idx, UniChar *ch);
325 CF_EXPORT int _CFStringCheckAndGetCharacters(CFStringRef str, CFRange range, UniChar *buffer);
326 CF_EXPORT CFIndex _CFStringGetLength2(CFStringRef str);
327 CF_EXPORT CFHashCode __CFStringHash(CFTypeRef cf);
328 CF_EXPORT CFHashCode CFStringHashISOLatin1CString(const uint8_t *bytes, CFIndex len);
329 CF_EXPORT CFHashCode CFStringHashCString(const uint8_t *bytes, CFIndex len);
330 CF_EXPORT CFHashCode CFStringHashCharacters(const UniChar *characters, CFIndex len);
331 CF_EXPORT CFHashCode CFStringHashNSString(CFStringRef str);
332
333
334 CF_EXTERN_C_END
335
336
337 // ---- Binary plist material ----------------------------------------
338
339 typedef const struct __CFKeyedArchiverUID * CFKeyedArchiverUIDRef;
340 CF_EXPORT CFTypeID _CFKeyedArchiverUIDGetTypeID(void);
341 CF_EXPORT CFKeyedArchiverUIDRef _CFKeyedArchiverUIDCreate(CFAllocatorRef allocator, uint32_t value);
342 CF_EXPORT uint32_t _CFKeyedArchiverUIDGetValue(CFKeyedArchiverUIDRef uid);
343
344
345 enum {
346 kCFBinaryPlistMarkerNull = 0x00,
347 kCFBinaryPlistMarkerFalse = 0x08,
348 kCFBinaryPlistMarkerTrue = 0x09,
349 kCFBinaryPlistMarkerFill = 0x0F,
350 kCFBinaryPlistMarkerInt = 0x10,
351 kCFBinaryPlistMarkerReal = 0x20,
352 kCFBinaryPlistMarkerDate = 0x33,
353 kCFBinaryPlistMarkerData = 0x40,
354 kCFBinaryPlistMarkerASCIIString = 0x50,
355 kCFBinaryPlistMarkerUnicode16String = 0x60,
356 kCFBinaryPlistMarkerUID = 0x80,
357 kCFBinaryPlistMarkerArray = 0xA0,
358 kCFBinaryPlistMarkerSet = 0xC0,
359 kCFBinaryPlistMarkerDict = 0xD0
360 };
361
362 typedef struct {
363 uint8_t _magic[6];
364 uint8_t _version[2];
365 } CFBinaryPlistHeader;
366
367 typedef struct {
368 uint8_t _unused[5];
369 uint8_t _sortVersion;
370 uint8_t _offsetIntSize;
371 uint8_t _objectRefSize;
372 uint64_t _numObjects;
373 uint64_t _topObject;
374 uint64_t _offsetTableOffset;
375 } CFBinaryPlistTrailer;
376
377
378 CF_EXPORT bool __CFBinaryPlistGetTopLevelInfo(const uint8_t *databytes, uint64_t datalen, uint8_t *marker, uint64_t *offset, CFBinaryPlistTrailer *trailer);
379 CF_EXPORT bool __CFBinaryPlistGetOffsetForValueFromArray2(const uint8_t *databytes, uint64_t datalen, uint64_t startOffset, const CFBinaryPlistTrailer *trailer, CFIndex idx, uint64_t *offset, CFMutableDictionaryRef objects);
380 CF_EXPORT bool __CFBinaryPlistGetOffsetForValueFromDictionary3(const uint8_t *databytes, uint64_t datalen, uint64_t startOffset, const CFBinaryPlistTrailer *trailer, CFTypeRef key, uint64_t *koffset, uint64_t *voffset, Boolean unused, CFMutableDictionaryRef objects);
381 CF_EXPORT bool __CFBinaryPlistCreateObject(const uint8_t *databytes, uint64_t datalen, uint64_t startOffset, const CFBinaryPlistTrailer *trailer, CFAllocatorRef allocator, CFOptionFlags mutabilityOption, CFMutableDictionaryRef objects, CFPropertyListRef *plist);
382 CF_EXPORT 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);
383 CF_EXPORT CFIndex __CFBinaryPlistWriteToStream(CFPropertyListRef plist, CFTypeRef stream);
384 CF_EXPORT CFIndex __CFBinaryPlistWriteToStreamWithEstimate(CFPropertyListRef plist, CFTypeRef stream, uint64_t estimate); // will be removed soon
385 CF_EXPORT CFIndex __CFBinaryPlistWriteToStreamWithOptions(CFPropertyListRef plist, CFTypeRef stream, uint64_t estimate, CFOptionFlags options); // will be removed soon
386 CF_EXPORT CFIndex __CFBinaryPlistWrite(CFPropertyListRef plist, CFTypeRef stream, uint64_t estimate, CFOptionFlags options, CFErrorRef *error);
387
388 // ---- Used by property list parsing in Foundation
389
390 CF_EXPORT CFTypeRef _CFPropertyListCreateFromXMLData(CFAllocatorRef allocator, CFDataRef xmlData, CFOptionFlags option, CFStringRef *errorString, Boolean allowNewTypes, CFPropertyListFormat *format);
391
392 CF_EXPORT CFTypeRef _CFPropertyListCreateFromXMLString(CFAllocatorRef allocator, CFStringRef xmlString, CFOptionFlags option, CFStringRef *errorString, Boolean allowNewTypes, CFPropertyListFormat *format);
393
394 CF_EXPORT bool _CFPropertyListCreateSingleValue(CFAllocatorRef allocator, CFDataRef data, CFOptionFlags option, CFStringRef key, CFPropertyListRef *value, CFErrorRef *error);
395
396 // ---- Sudden Termination material ----------------------------------------
397
398 #if DEPLOYMENT_TARGET_MACOSX
399
400 CF_EXPORT void _CFSuddenTerminationDisable(void);
401 CF_EXPORT void _CFSuddenTerminationEnable(void);
402 CF_EXPORT void _CFSuddenTerminationExitIfTerminationEnabled(int exitStatus);
403 CF_EXPORT void _CFSuddenTerminationExitWhenTerminationEnabled(int exitStatus);
404 CF_EXPORT size_t _CFSuddenTerminationDisablingCount(void);
405
406 #endif
407
408 #if DEPLOYMENT_TARGET_WINDOWS
409 // ---- Windows-specific material ---------------------------------------
410
411 // These are replacements for POSIX calls on Windows, ensuring that the UTF8 parameters are converted to UTF16 before being passed to Windows
412 CF_EXPORT int _NS_stat(const char *name, struct _stat *st);
413 CF_EXPORT int _NS_mkdir(const char *name);
414 CF_EXPORT int _NS_rmdir(const char *name);
415 CF_EXPORT int _NS_chmod(const char *name, int mode);
416 CF_EXPORT int _NS_unlink(const char *name);
417 CF_EXPORT char *_NS_getcwd(char *dstbuf, size_t size); // Warning: this doesn't support dstbuf as null even though 'getcwd' does
418 CF_EXPORT char *_NS_getenv(const char *name);
419 CF_EXPORT int _NS_rename(const char *oldName, const char *newName);
420 CF_EXPORT int _NS_open(const char *name, int oflag, int pmode);
421 CF_EXPORT int _NS_mkstemp(char *name, int bufSize);
422 #endif
423
424 // ---- Miscellaneous material ----------------------------------------
425
426 #include <CoreFoundation/CFBag.h>
427 #include <CoreFoundation/CFSet.h>
428 #include <math.h>
429
430 CF_EXTERN_C_BEGIN
431
432 CF_EXPORT CFTypeID CFTypeGetTypeID(void);
433
434 CF_EXPORT CFTypeRef _CFRetainGC(CFTypeRef cf);
435 CF_EXPORT void _CFReleaseGC(CFTypeRef cf);
436
437 CF_EXPORT void _CFArraySetCapacity(CFMutableArrayRef array, CFIndex cap);
438 CF_EXPORT void _CFBagSetCapacity(CFMutableBagRef bag, CFIndex cap);
439 CF_EXPORT void _CFDictionarySetCapacity(CFMutableDictionaryRef dict, CFIndex cap);
440 CF_EXPORT void _CFSetSetCapacity(CFMutableSetRef set, CFIndex cap);
441
442 CF_EXPORT void CFCharacterSetCompact(CFMutableCharacterSetRef theSet);
443 CF_EXPORT void CFCharacterSetFast(CFMutableCharacterSetRef theSet);
444
445 CF_EXPORT const void *_CFArrayCheckAndGetValueAtIndex(CFArrayRef array, CFIndex idx);
446 CF_EXPORT void _CFArrayReplaceValues(CFMutableArrayRef array, CFRange range, const void **newValues, CFIndex newCount);
447
448
449 /* Enumeration
450 Call CFStartSearchPathEnumeration() once, then call
451 CFGetNextSearchPathEnumeration() one or more times with the returned state.
452 The return value of CFGetNextSearchPathEnumeration() should be used as
453 the state next time around.
454 When CFGetNextSearchPathEnumeration() returns 0, you're done.
455 */
456 typedef CFIndex CFSearchPathEnumerationState;
457 CF_EXPORT CFSearchPathEnumerationState __CFStartSearchPathEnumeration(CFSearchPathDirectory dir, CFSearchPathDomainMask domainMask);
458 CF_EXPORT CFSearchPathEnumerationState __CFGetNextSearchPathEnumeration(CFSearchPathEnumerationState state, UInt8 *path, CFIndex pathSize);
459
460 /* For use by NSNumber and CFNumber.
461 Hashing algorithm for CFNumber:
462 M = Max CFHashCode (assumed to be unsigned)
463 For positive integral values: (N * HASHFACTOR) mod M
464 For negative integral values: ((-N) * HASHFACTOR) mod M
465 For floating point numbers that are not integral: hash(integral part) + hash(float part * M)
466 HASHFACTOR is 2654435761, from Knuth's multiplicative method
467 */
468 #define HASHFACTOR 2654435761U
469
470 CF_INLINE CFHashCode _CFHashInt(long i) {
471 return ((i > 0) ? (CFHashCode)(i) : (CFHashCode)(-i)) * HASHFACTOR;
472 }
473
474 CF_INLINE CFHashCode _CFHashDouble(double d) {
475 double dInt;
476 if (d < 0) d = -d;
477 dInt = floor(d+0.5);
478 CFHashCode integralHash = HASHFACTOR * (CFHashCode)fmod(dInt, (double)ULONG_MAX);
479 return (CFHashCode)(integralHash + (CFHashCode)((d - dInt) * ULONG_MAX));
480 }
481
482
483 /* 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.
484 */
485 CF_EXPORT CFStringRef _CFErrorCreateLocalizedDescription(CFErrorRef err);
486 CF_EXPORT CFStringRef _CFErrorCreateLocalizedFailureReason(CFErrorRef err);
487 CF_EXPORT CFStringRef _CFErrorCreateLocalizedRecoverySuggestion(CFErrorRef err);
488 CF_EXPORT CFStringRef _CFErrorCreateDebugDescription(CFErrorRef err);
489
490 CF_EXPORT CFURLRef _CFURLAlloc(CFAllocatorRef allocator);
491 CF_EXPORT void _CFURLInitWithString(CFURLRef url, CFStringRef string, CFURLRef baseURL);
492 CF_EXPORT void _CFURLInitFSPath(CFURLRef url, CFStringRef path);
493 CF_EXPORT Boolean _CFStringIsLegalURLString(CFStringRef string);
494 CF_EXPORT void *__CFURLReservedPtr(CFURLRef url);
495 CF_EXPORT void __CFURLSetReservedPtr(CFURLRef url, void *ptr);
496 CF_EXPORT CFStringEncoding _CFURLGetEncoding(CFURLRef url);
497
498 CF_EXPORT Boolean _CFRunLoopFinished(CFRunLoopRef rl, CFStringRef mode);
499
500 CF_EXPORT CFIndex _CFStreamInstanceSize(void);
501
502 #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED
503 typedef struct {
504 mach_vm_address_t address;
505 mach_vm_size_t size;
506 mach_port_t port;
507 bool purgeable;
508 bool corporeal;
509 bool volatyle;
510 uintptr_t reserved;
511 } CFDiscorporateMemory;
512
513 extern kern_return_t _CFDiscorporateMemoryAllocate(CFDiscorporateMemory *hm, size_t size, bool purgeable);
514 extern kern_return_t _CFDiscorporateMemoryDeallocate(CFDiscorporateMemory *hm);
515 extern kern_return_t _CFDiscorporateMemoryDematerialize(CFDiscorporateMemory *hm);
516 extern kern_return_t _CFDiscorporateMemoryMaterialize(CFDiscorporateMemory *hm);
517 #endif
518
519 CF_EXPORT CFRange _CFDataFindBytes(CFDataRef data, CFDataRef dataToFind, CFRange searchRange, CFDataSearchFlags compareOptions);
520
521
522 #if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED
523 #if !defined(__CFReadTSR)
524 #include <mach/mach_time.h>
525 #define __CFReadTSR() mach_absolute_time()
526 #endif
527 #elif DEPLOYMENT_TARGET_WINDOWS
528 #if 0
529 CF_INLINE UInt64 __CFReadTSR(void) {
530 LARGE_INTEGER freq;
531 QueryPerformanceCounter(&freq);
532 return freq.QuadPart;
533 }
534 #endif
535 #endif
536
537
538 CF_EXTERN_C_END
539
540 #endif /* ! __COREFOUNDATION_FORFOUNDATIONONLY__ */
541