]> git.saurik.com Git - apple/cf.git/blob - CFPriv.h
CF-744.12.tar.gz
[apple/cf.git] / CFPriv.h
1 /*
2 * Copyright (c) 2012 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 /* CFPriv.h
25 Copyright (c) 1998-2012, Apple Inc. All rights reserved.
26 */
27
28 /*
29 APPLE SPI: NOT TO BE USED OUTSIDE APPLE!
30 */
31
32 #if !defined(__COREFOUNDATION_CFPRIV__)
33 #define __COREFOUNDATION_CFPRIV__ 1
34
35 #include <string.h>
36 #include <CoreFoundation/CFBase.h>
37 #include <CoreFoundation/CFArray.h>
38 #include <CoreFoundation/CFString.h>
39 #include <CoreFoundation/CFURL.h>
40 #include <CoreFoundation/CFLocale.h>
41 #include <CoreFoundation/CFDate.h>
42 #include <CoreFoundation/CFSet.h>
43 #include <math.h>
44
45
46
47 #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_LINUX)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)
48 #include <CoreFoundation/CFMachPort.h>
49 #endif
50
51 #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) || TARGET_OS_WIN32
52 #include <CoreFoundation/CFRunLoop.h>
53 #include <CoreFoundation/CFSocket.h>
54 #include <CoreFoundation/CFBundlePriv.h>
55 #endif
56
57 CF_EXTERN_C_BEGIN
58
59 CF_EXPORT intptr_t _CFDoOperation(intptr_t code, intptr_t subcode1, intptr_t subcode2);
60
61 CF_EXPORT void _CFRuntimeSetCFMPresent(void *a);
62
63 CF_EXPORT const char *_CFProcessPath(void);
64 CF_EXPORT const char **_CFGetProcessPath(void);
65 CF_EXPORT const char **_CFGetProgname(void);
66
67
68 #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_LINUX))
69 CF_EXPORT void _CFRunLoopSetCurrent(CFRunLoopRef rl);
70 #endif
71
72 #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_LINUX)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)
73 CF_EXPORT CFRunLoopRef CFRunLoopGetMain(void);
74 CF_EXPORT SInt32 CFRunLoopRunSpecific(CFRunLoopRef rl, CFStringRef modeName, CFTimeInterval seconds, Boolean returnAfterSourceHandled);
75
76
77 CF_EXPORT void _CFRunLoopStopMode(CFRunLoopRef rl, CFStringRef modeName);
78
79 CF_EXPORT CFIndex CFMachPortGetQueuedMessageCount(CFMachPortRef mp);
80
81 CF_EXPORT CFPropertyListRef _CFURLCopyPropertyListRepresentation(CFURLRef url);
82 #endif
83 CF_EXPORT CFPropertyListRef _CFURLCopyPropertyListRepresentation(CFURLRef url);
84 CF_EXPORT CFURLRef _CFURLCreateFromPropertyListRepresentation(CFAllocatorRef alloc, CFPropertyListRef pListRepresentation);
85
86 CF_EXPORT void CFPreferencesFlushCaches(void);
87
88 #if TARGET_OS_WIN32
89 CF_EXPORT Boolean _CFURLGetWideFileSystemRepresentation(CFURLRef url, Boolean resolveAgainstBase, wchar_t *buffer, CFIndex bufferLength);
90 #endif
91
92 #if !__LP64__
93 #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)
94 struct FSSpec;
95 CF_EXPORT
96 Boolean _CFGetFSSpecFromURL(CFAllocatorRef alloc, CFURLRef url, struct FSSpec *spec);
97
98 CF_EXPORT
99 CFURLRef _CFCreateURLFromFSSpec(CFAllocatorRef alloc, const struct FSSpec *voidspec, Boolean isDirectory);
100 #endif
101 #endif
102
103 typedef CF_ENUM(CFIndex, CFURLComponentDecomposition) {
104 kCFURLComponentDecompositionNonHierarchical,
105 kCFURLComponentDecompositionRFC1808, /* use this for RFC 1738 decompositions as well */
106 kCFURLComponentDecompositionRFC2396
107 };
108
109 typedef struct {
110 CFStringRef scheme;
111 CFStringRef schemeSpecific;
112 } CFURLComponentsNonHierarchical;
113
114 typedef struct {
115 CFStringRef scheme;
116 CFStringRef user;
117 CFStringRef password;
118 CFStringRef host;
119 CFIndex port; /* kCFNotFound means ignore/omit */
120 CFArrayRef pathComponents;
121 CFStringRef parameterString;
122 CFStringRef query;
123 CFStringRef fragment;
124 CFURLRef baseURL;
125 } CFURLComponentsRFC1808;
126
127 typedef struct {
128 CFStringRef scheme;
129
130 /* if the registered name form of the net location is used, userinfo is NULL, port is kCFNotFound, and host is the entire registered name. */
131 CFStringRef userinfo;
132 CFStringRef host;
133 CFIndex port;
134
135 CFArrayRef pathComponents;
136 CFStringRef query;
137 CFStringRef fragment;
138 CFURLRef baseURL;
139 } CFURLComponentsRFC2396;
140
141 /* 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 */
142 CF_EXPORT
143 Boolean _CFURLCopyComponents(CFURLRef url, CFURLComponentDecomposition decompositionType, void *components);
144
145 /* Creates and returns the URL described by components; components should point to the CFURLComponents struct defined above that matches decompositionType. */
146 CF_EXPORT
147 CFURLRef _CFURLCreateFromComponents(CFAllocatorRef alloc, CFURLComponentDecomposition decompositionType, const void *components);
148 #define CFURLCopyComponents _CFURLCopyComponents
149 #define CFURLCreateFromComponents _CFURLCreateFromComponents
150
151
152
153 CF_EXPORT Boolean _CFStringGetFileSystemRepresentation(CFStringRef string, UInt8 *buffer, CFIndex maxBufLen);
154
155 /* If this is publicized, we might need to create a GetBytesPtr type function as well. */
156 CF_EXPORT CFStringRef _CFStringCreateWithBytesNoCopy(CFAllocatorRef alloc, const UInt8 *bytes, CFIndex numBytes, CFStringEncoding encoding, Boolean externalFormat, CFAllocatorRef contentsDeallocator);
157
158 /* These return NULL on MacOS 8 */
159 // This one leaks the returned string in order to be thread-safe.
160 // CF cannot help you in this matter if you continue to use this SPI.
161 CF_EXPORT
162 CFStringRef CFGetUserName(void);
163
164 CF_EXPORT
165 CFStringRef CFCopyUserName(void);
166
167 CF_EXPORT
168 CFURLRef CFCopyHomeDirectoryURLForUser(CFStringRef uName); /* Pass NULL for the current user's home directory */
169
170
171 /*
172 CFCopySearchPathForDirectoriesInDomains returns the various
173 standard system directories where apps, resources, etc get
174 installed. Because queries can return multiple directories,
175 you get back a CFArray (which you should free when done) of
176 CFURLs. The directories are returned in search path order;
177 that is, the first place to look is returned first. This API
178 may return directories that do not exist yet. If NSUserDomain
179 is included in a query, then the results will contain "~" to
180 refer to the user's directory. Specify expandTilde to expand
181 this to the current user's home. Some calls might return no
182 directories!
183 ??? On MacOS 8 this function currently returns an empty array.
184 */
185 typedef CF_ENUM(CFIndex, CFSearchPathDirectory) {
186 kCFApplicationDirectory = 1, /* supported applications (Applications) */
187 kCFDemoApplicationDirectory, /* unsupported applications, demonstration versions (Demos) */
188 kCFDeveloperApplicationDirectory, /* developer applications (Developer/Applications) */
189 kCFAdminApplicationDirectory, /* system and network administration applications (Administration) */
190 kCFLibraryDirectory, /* various user-visible documentation, support, and configuration files, resources (Library) */
191 kCFDeveloperDirectory, /* developer resources (Developer) */
192 kCFUserDirectory, /* user home directories (Users) */
193 kCFDocumentationDirectory, /* documentation (Documentation) */
194 kCFDocumentDirectory, /* documents (Library/Documents) */
195
196 kCFCoreServiceDirectory = 10, // location of CoreServices directory (System/Library/CoreServices)
197 kCFAutosavedInformationDirectory = 11, // location of autosaved documents (Documents/Autosaved)
198 kCFDesktopDirectory = 12, // location of user's desktop
199 kCFCachesDirectory = 13, // location of discardable cache files (Library/Caches)
200 kCFApplicationSupportDirectory = 14, // location of application support files (plug-ins, etc) (Library/Application Support)
201 kCFDownloadsDirectory = 15, // location of the user's "Downloads" directory
202 kCFInputMethodsDirectory = 16, // input methods (Library/Input Methods)
203 kCFMoviesDirectory = 17, // location of user's Movies directory (~/Movies)
204 kCFMusicDirectory = 18, // location of user's Music directory (~/Music)
205 kCFPicturesDirectory = 19, // location of user's Pictures directory (~/Pictures)
206 kCFPrinterDescriptionDirectory = 20, // location of system's PPDs directory (Library/Printers/PPDs)
207 kCFSharedPublicDirectory = 21, // location of user's Public sharing directory (~/Public)
208 kCFPreferencePanesDirectory = 22, // location of the PreferencePanes directory for use with System Preferences (Library/PreferencePanes)
209
210 kCFAllApplicationsDirectory = 100, /* all directories where applications can occur (ie Applications, Demos, Administration, Developer/Applications) */
211 kCFAllLibrariesDirectory = 101 /* all directories where resources can occur (Library, Developer) */
212 };
213
214 typedef CF_OPTIONS(CFOptionFlags, CFSearchPathDomainMask) {
215 kCFUserDomainMask = 1, /* user's home directory --- place to install user's personal items (~) */
216 kCFLocalDomainMask = 2, /* local to the current machine --- place to install items available to everyone on this machine (/Local) */
217 kCFNetworkDomainMask = 4, /* publically available location in the local area network --- place to install items available on the network (/Network) */
218 kCFSystemDomainMask = 8, /* provided by Apple, unmodifiable (/System) */
219 kCFAllDomainsMask = 0x0ffff /* all domains: all of the above and more, future items */
220 };
221
222 CF_EXPORT
223 CFArrayRef CFCopySearchPathForDirectoriesInDomains(CFSearchPathDirectory directory, CFSearchPathDomainMask domainMask, Boolean expandTilde);
224
225 /* Obsolete keys */
226 CF_EXPORT const CFStringRef kCFFileURLExists;
227 CF_EXPORT const CFStringRef kCFFileURLPOSIXMode;
228 CF_EXPORT const CFStringRef kCFFileURLSize;
229 CF_EXPORT const CFStringRef kCFFileURLDirectoryContents;
230 CF_EXPORT const CFStringRef kCFFileURLLastModificationTime;
231 CF_EXPORT const CFStringRef kCFHTTPURLStatusCode;
232 CF_EXPORT const CFStringRef kCFHTTPURLStatusLine;
233
234
235 /* System Version file access */
236 CF_EXPORT CFStringRef CFCopySystemVersionString(void); // Human-readable string containing both marketing and build version
237 CF_EXPORT CFDictionaryRef _CFCopySystemVersionDictionary(void);
238 CF_EXPORT CFDictionaryRef _CFCopyServerVersionDictionary(void);
239 CF_EXPORT const CFStringRef _kCFSystemVersionProductNameKey;
240 CF_EXPORT const CFStringRef _kCFSystemVersionProductCopyrightKey;
241 CF_EXPORT const CFStringRef _kCFSystemVersionProductVersionKey;
242 CF_EXPORT const CFStringRef _kCFSystemVersionProductVersionExtraKey;
243 CF_EXPORT const CFStringRef _kCFSystemVersionProductUserVisibleVersionKey; // For loginwindow; see 2987512
244 CF_EXPORT const CFStringRef _kCFSystemVersionBuildVersionKey;
245 CF_EXPORT const CFStringRef _kCFSystemVersionProductVersionStringKey; // Localized string for the string "Version"
246 CF_EXPORT const CFStringRef _kCFSystemVersionBuildStringKey; // Localized string for the string "Build"
247
248
249 CF_EXPORT void CFMergeSortArray(void *list, CFIndex count, CFIndex elementSize, CFComparatorFunction comparator, void *context);
250 CF_EXPORT void CFQSortArray(void *list, CFIndex count, CFIndex elementSize, CFComparatorFunction comparator, void *context);
251
252 /* _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.
253 This function caches its results, so no need to cache at call sites.
254
255 Note that for non-MACH this function always returns true.
256 */
257 typedef CF_ENUM(CFIndex, CFSystemVersion) {
258 CFSystemVersionCheetah = 0, /* 10.0 */
259 CFSystemVersionPuma = 1, /* 10.1 */
260 CFSystemVersionJaguar = 2, /* 10.2 */
261 CFSystemVersionPanther = 3, /* 10.3 */
262 CFSystemVersionTiger = 4, /* 10.4 */
263 CFSystemVersionLeopard = 5, /* 10.5 */
264 CFSystemVersionSnowLeopard = 6, /* 10.6 */
265 CFSystemVersionLion = 7, /* 10.7 */
266 CFSystemVersionMountainLion = 8, /* 10.8 */
267 CFSystemVersionMax, /* This should bump up when new entries are added */
268
269 };
270
271 CF_EXPORT Boolean _CFExecutableLinkedOnOrAfter(CFSystemVersion version);
272
273
274 typedef CF_ENUM(CFIndex, CFStringCharacterClusterType) {
275 kCFStringGraphemeCluster = 1, /* Unicode Grapheme Cluster */
276 kCFStringComposedCharacterCluster = 2, /* Compose all non-base (including spacing marks) */
277 kCFStringCursorMovementCluster = 3, /* Cluster suitable for cursor movements */
278 kCFStringBackwardDeletionCluster = 4 /* Cluster suitable for backward deletion */
279 };
280
281 CF_EXPORT CFRange CFStringGetRangeOfCharacterClusterAtIndex(CFStringRef string, CFIndex charIndex, CFStringCharacterClusterType type);
282
283 // Compatibility kCFCompare flags. Use the new public kCFCompareDiacriticInsensitive
284 enum {
285 kCFCompareDiacriticsInsensitive = 128 /* Use kCFCompareDiacriticInsensitive */
286 };
287
288 /* kCFCompare flags planned to be publicized (Aki 10/20/2008 Does not work with kCFCompareForceOrdering/CFStringFold). see <rdar://problem/6305147>)
289 */
290 enum {
291 kCFCompareIgnoreNonAlphanumeric = (1UL << 16), // Ignores characters NOT in kCFCharacterSetAlphaNumeric
292 };
293
294
295 /* CFStringEncoding SPI */
296 /* When set, CF encoding conversion engine keeps ASCII compatibility. (i.e. ASCII backslash <-> Unicode backslash in MacJapanese */
297 CF_EXPORT void _CFStringEncodingSetForceASCIICompatibility(Boolean flag);
298
299 extern void __CFSetCharToUniCharFunc(Boolean (*func)(UInt32 flags, UInt8 ch, UniChar *unicodeChar));
300 extern UniChar __CFCharToUniCharTable[256];
301
302
303 #if defined(CF_INLINE)
304 CF_INLINE const UniChar *CFStringGetCharactersPtrFromInlineBuffer(CFStringInlineBuffer *buf, CFRange desiredRange) {
305 if ((desiredRange.location < 0) || ((desiredRange.location + desiredRange.length) > buf->rangeToBuffer.length)) return NULL;
306
307 if (buf->directBuffer) {
308 return buf->directBuffer + buf->rangeToBuffer.location + desiredRange.location;
309 } else {
310 if (desiredRange.length > __kCFStringInlineBufferLength) return NULL;
311
312 if (((desiredRange.location + desiredRange.length) > buf->bufferedRangeEnd) || (desiredRange.location < buf->bufferedRangeStart)) {
313 buf->bufferedRangeStart = desiredRange.location;
314 buf->bufferedRangeEnd = buf->bufferedRangeStart + __kCFStringInlineBufferLength;
315 if (buf->bufferedRangeEnd > buf->rangeToBuffer.length) buf->bufferedRangeEnd = buf->rangeToBuffer.length;
316 CFStringGetCharacters(buf->theString, CFRangeMake(buf->rangeToBuffer.location + buf->bufferedRangeStart, buf->bufferedRangeEnd - buf->bufferedRangeStart), buf->buffer);
317 }
318
319 return buf->buffer + (desiredRange.location - buf->bufferedRangeStart);
320 }
321 }
322
323 CF_INLINE void CFStringGetCharactersFromInlineBuffer(CFStringInlineBuffer *buf, CFRange desiredRange, UniChar *outBuf) {
324 if (buf->directBuffer) {
325 memmove(outBuf, buf->directBuffer + buf->rangeToBuffer.location + desiredRange.location, desiredRange.length * sizeof(UniChar));
326 } else {
327 if ((desiredRange.location >= buf->bufferedRangeStart) && (desiredRange.location < buf->bufferedRangeEnd)) {
328 CFIndex bufLen = desiredRange.length;
329
330 if (bufLen > (buf->bufferedRangeEnd - desiredRange.location)) bufLen = (buf->bufferedRangeEnd - desiredRange.location);
331
332 memmove(outBuf, buf->buffer + (desiredRange.location - buf->bufferedRangeStart), bufLen * sizeof(UniChar));
333 outBuf += bufLen; desiredRange.location += bufLen; desiredRange.length -= bufLen;
334 } else {
335 CFIndex desiredRangeMax = (desiredRange.location + desiredRange.length);
336
337 if ((desiredRangeMax > buf->bufferedRangeStart) && (desiredRangeMax < buf->bufferedRangeEnd)) {
338 desiredRange.length = (buf->bufferedRangeStart - desiredRange.location);
339 memmove(outBuf + desiredRange.length, buf->buffer, (desiredRangeMax - buf->bufferedRangeStart) * sizeof(UniChar));
340 }
341 }
342
343 if (desiredRange.length > 0) CFStringGetCharacters(buf->theString, CFRangeMake(buf->rangeToBuffer.location + desiredRange.location, desiredRange.length), outBuf);
344 }
345 }
346
347 #else
348 #define CFStringGetCharactersPtrFromInlineBuffer(buf, desiredRange) ((buf)->directBuffer ? (buf)->directBuffer + (buf)->rangeToBuffer.location + desiredRange.location : NULL)
349
350 #define CFStringGetCharactersFromInlineBuffer(buf, desiredRange, outBuf) \
351 if (buf->directBuffer) memmove(outBuf, (buf)->directBuffer + (buf)->rangeToBuffer.location + desiredRange.location, desiredRange.length * sizeof(UniChar)); \
352 else CFStringGetCharacters((buf)->theString, CFRangeMake((buf)->rangeToBuffer.location + desiredRange.location, desiredRange.length), outBuf);
353
354 #endif /* CF_INLINE */
355
356 /*
357 CFCharacterSetInlineBuffer related declarations
358 */
359 /*!
360 @typedef CFCharacterSetInlineBuffer
361 @field cset The character set this inline buffer is initialized with.
362 The object is not retained by the structure.
363 @field flags The field is a bit mask that carries various settings.
364 @field rangeStart The beginning of the character range that contains all members.
365 It is guaranteed that there is no member below this value.
366 @field rangeLimit The end of the character range that contains all members.
367 It is guaranteed that there is no member above and equal to this value.
368 @field bitmap The bitmap data representing the membership of the Basic Multilingual Plane characters.
369 If NULL, all BMP characters inside the range are members of the character set.
370 */
371 typedef struct {
372 CFCharacterSetRef cset;
373 uint32_t flags;
374 uint32_t rangeStart;
375 uint32_t rangeLimit;
376 const uint8_t *bitmap;
377 } CFCharacterSetInlineBuffer;
378
379 // Bits for flags field
380 enum {
381 kCFCharacterSetIsCompactBitmap = (1UL << 0),
382 kCFCharacterSetNoBitmapAvailable = (1UL << 1),
383 kCFCharacterSetIsInverted = (1UL << 2)
384 };
385
386 /*!
387 @function CFCharacterSetInitInlineBuffer
388 Initializes buffer with cset.
389 @param cset The character set used to initialized the buffer.
390 If this parameter is not a valid CFCharacterSet, the behavior is undefined.
391 @param buffer The reference to the inline buffer to be initialized.
392 */
393 CF_EXPORT
394 void CFCharacterSetInitInlineBuffer(CFCharacterSetRef cset, CFCharacterSetInlineBuffer *buffer);
395
396 /*!
397 @function CFCharacterSetInlineBufferIsLongCharacterMember
398 Reports whether or not the UTF-32 character is in the character set.
399 @param buffer The reference to the inline buffer to be searched.
400 @param character The UTF-32 character for which to test against the
401 character set.
402 @result true, if the value is in the character set, otherwise false.
403 */
404 #if defined(CF_INLINE)
405 CF_INLINE bool CFCharacterSetInlineBufferIsLongCharacterMember(CFCharacterSetInlineBuffer *buffer, UTF32Char character) {
406 bool isInverted = ((0 == (buffer->flags & kCFCharacterSetIsInverted)) ? false : true);
407
408 if ((character >= buffer->rangeStart) && (character < buffer->rangeLimit)) {
409 if ((character > 0xFFFF) || (0 != (buffer->flags & kCFCharacterSetNoBitmapAvailable))) return (CFCharacterSetIsLongCharacterMember(buffer->cset, character) != 0);
410 if (NULL == buffer->bitmap) {
411 if (0 == (buffer->flags & kCFCharacterSetIsCompactBitmap)) isInverted = !isInverted;
412 } else if (0 == (buffer->flags & kCFCharacterSetIsCompactBitmap)) {
413 if (buffer->bitmap[character >> 3] & (1UL << (character & 7))) isInverted = !isInverted;
414 } else {
415 uint8_t value = buffer->bitmap[character >> 8];
416
417 if (value == 0xFF) {
418 isInverted = !isInverted;
419 } else if (value > 0) {
420 const uint8_t *segment = buffer->bitmap + (256 + (32 * (value - 1)));
421 character &= 0xFF;
422 if (segment[character >> 3] & (1UL << (character % 8))) isInverted = !isInverted;
423 }
424 }
425 }
426 return isInverted;
427 }
428 #else /* CF_INLINE */
429 #define CFCharacterSetInlineBufferIsLongCharacterMember(buffer, character) (CFCharacterSetIsLongCharacterMember(buffer->cset, character))
430 #endif /* CF_INLINE */
431
432
433 #if TARGET_OS_WIN32
434 CF_EXPORT CFMutableStringRef _CFCreateApplicationRepositoryPath(CFAllocatorRef alloc, int nFolder);
435 #endif
436
437 CF_EXPORT CFTypeRef _CFTryRetain(CFTypeRef cf);
438 CF_EXPORT Boolean _CFIsDeallocating(CFTypeRef cf);
439
440 /*
441 CFLocaleGetLanguageRegionEncodingForLocaleIdentifier gets the appropriate language and region codes,
442 and the default legacy script code and encoding, for the specified locale (or language) string.
443 Returns false if CFLocale has no information about the given locale; otherwise may set
444 *langCode and/or *regCode to -1 if there is no appropriate legacy value for the locale.
445 This is a replacement for the CFBundle SPI CFBundleGetLocalizationInfoForLocalization (which was intended to be temporary and transitional);
446 this function is more up-to-date in its handling of locale strings, and is in CFLocale where this functionality should belong. Compared
447 to CFBundleGetLocalizationInfoForLocalization, this function does not spcially interpret a NULL localeIdentifier to mean use the single most
448 preferred localization in the current context (this function returns NO for a NULL localeIdentifier); and in this function
449 langCode, regCode, and scriptCode are all SInt16* (not SInt32* like the equivalent parameters in CFBundleGetLocalizationInfoForLocalization).
450 */
451 CF_EXPORT
452 Boolean CFLocaleGetLanguageRegionEncodingForLocaleIdentifier(CFStringRef localeIdentifier, LangCode *langCode, RegionCode *regCode, ScriptCode *scriptCode, CFStringEncoding *stringEncoding);
453
454 #if TARGET_OS_WIN32
455 CF_EXPORT CFMutableStringRef _CFCreateApplicationRepositoryPath(CFAllocatorRef alloc, int nFolder);
456 #endif
457
458 #if TARGET_OS_WIN32
459 #include <CoreFoundation/CFMessagePort.h>
460
461 #define CF_MESSAGE_PORT_CLONE_MESSAGE_ID -1209
462 CF_EXPORT CFMessagePortRef CFMessagePortCreateUber(CFAllocatorRef allocator, CFStringRef name, CFMessagePortCallBack callout, CFMessagePortContext *context, Boolean *shouldFreeInfo, Boolean isRemote);
463 CF_EXPORT void CFMessagePortSetCloneCallout(CFMessagePortRef ms, CFMessagePortCallBack cloneCallout);
464 #endif
465
466 #if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_LINUX)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)
467 #include <CoreFoundation/CFMessagePort.h>
468
469 CF_EXPORT CFMessagePortRef CFMessagePortCreatePerProcessLocal(CFAllocatorRef allocator, CFStringRef name, CFMessagePortCallBack callout, CFMessagePortContext *context, Boolean *shouldFreeInfo);
470 CF_EXPORT CFMessagePortRef CFMessagePortCreatePerProcessRemote(CFAllocatorRef allocator, CFStringRef name, CFIndex pid);
471
472
473 typedef CFDataRef (*CFMessagePortCallBackEx)(CFMessagePortRef local, SInt32 msgid, CFDataRef data, void *info, void *trailer, uintptr_t);
474
475 CF_EXPORT CFMessagePortRef _CFMessagePortCreateLocalEx(CFAllocatorRef allocator, CFStringRef name, Boolean perPID, uintptr_t unused, CFMessagePortCallBackEx callout2, CFMessagePortContext *context, Boolean *shouldFreeInfo);
476
477 #endif
478
479 #if TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_LINUX
480 #include <pthread.h>
481 #else
482 // Avoid including the pthread header
483 #ifndef HAVE_STRUCT_TIMESPEC
484 #define HAVE_STRUCT_TIMESPEC 1
485 struct timespec { long tv_sec; long tv_nsec; };
486 #endif
487 #endif
488
489 CF_INLINE CFAbsoluteTime _CFAbsoluteTimeFromFileTimeSpec(struct timespec ts) {
490 return (CFAbsoluteTime)((CFTimeInterval)ts.tv_sec - kCFAbsoluteTimeIntervalSince1970) + (1.0e-9 * (CFTimeInterval)ts.tv_nsec);
491 }
492
493 CF_INLINE struct timespec _CFFileTimeSpecFromAbsoluteTime(CFAbsoluteTime at) {
494 struct timespec ts;
495 double sec = 0.0;
496 double frac = modf(at, &sec);
497 if (frac < 0.0) {
498 frac += 1.0;
499 sec -= 1.0;
500 }
501 #if TARGET_OS_WIN32
502 ts.tv_sec = (long)(sec + kCFAbsoluteTimeIntervalSince1970);
503 #else
504 ts.tv_sec = (time_t)(sec + kCFAbsoluteTimeIntervalSince1970);
505 #endif
506 ts.tv_nsec = (long)(1000000000UL * frac + 0.5);
507 return ts;
508 }
509
510 // The 'filtered' function below is preferred to this older one
511 CF_EXPORT bool _CFPropertyListCreateSingleValue(CFAllocatorRef allocator, CFDataRef data, CFOptionFlags option, CFStringRef keyPath, CFPropertyListRef *value, CFErrorRef *error);
512
513 // Returns a subset of the property list, only including the keyPaths in the CFSet. If the top level object is not a dictionary, you will get back an empty dictionary as the result.
514 CF_EXPORT bool _CFPropertyListCreateFiltered(CFAllocatorRef allocator, CFDataRef data, CFOptionFlags option, CFSetRef keyPaths, CFPropertyListRef *value, CFErrorRef *error) CF_AVAILABLE(10_8, 6_0);
515
516 // Returns a subset of a bundle's Info.plist. The keyPaths follow the same rules as above CFPropertyList function. This function takes platform and product keys into account.
517 typedef CF_OPTIONS(CFOptionFlags, _CFBundleFilteredPlistOptions) {
518 _CFBundleFilteredPlistMemoryMapped = 1
519 } CF_ENUM_AVAILABLE(10_8, 6_0);
520
521 CF_EXPORT CFPropertyListRef _CFBundleCreateFilteredInfoPlist(CFBundleRef bundle, CFSetRef keyPaths, _CFBundleFilteredPlistOptions options) CF_AVAILABLE(10_8, 6_0);
522 CF_EXPORT CFPropertyListRef _CFBundleCreateFilteredLocalizedInfoPlist(CFBundleRef bundle, CFSetRef keyPaths, CFStringRef localizationName, _CFBundleFilteredPlistOptions options) CF_AVAILABLE(10_8, 6_0);
523
524 #if TARGET_OS_WIN32
525 #include <CoreFoundation/CFNotificationCenter.h>
526
527 CF_EXPORT CFStringRef _CFGetWindowsAppleAppDataDirectory(void);
528 CF_EXPORT CFArrayRef _CFGetWindowsBinaryDirectories(void);
529 CF_EXPORT CFStringRef _CFGetWindowsAppleSystemLibraryDirectory(void);
530
531 // If your Windows application does not use a CFRunLoop on the main thread (perhaps because it is reserved for handling UI events via Windows API), then call this function to make distributed notifications arrive using a different run loop.
532 CF_EXPORT void _CFNotificationCenterSetRunLoop(CFNotificationCenterRef nc, CFRunLoopRef rl);
533
534 CF_EXPORT uint32_t /*DWORD*/ _CFRunLoopGetWindowsMessageQueueMask(CFRunLoopRef rl, CFStringRef modeName);
535 CF_EXPORT void _CFRunLoopSetWindowsMessageQueueMask(CFRunLoopRef rl, uint32_t /*DWORD*/ mask, CFStringRef modeName);
536
537 CF_EXPORT uint32_t /*DWORD*/ _CFRunLoopGetWindowsThreadID(CFRunLoopRef rl);
538
539 typedef void (*CFWindowsMessageQueueHandler)(void);
540
541 // Run Loop parameter must be the current thread's run loop for the next two functions; you cannot use another thread's run loop
542 CF_EXPORT CFWindowsMessageQueueHandler _CFRunLoopGetWindowsMessageQueueHandler(CFRunLoopRef rl, CFStringRef modeName);
543 CF_EXPORT void _CFRunLoopSetWindowsMessageQueueHandler(CFRunLoopRef rl, CFStringRef modeName, CFWindowsMessageQueueHandler func);
544
545 #endif
546
547
548 CF_EXPORT CFArrayRef CFDateFormatterCreateDateFormatsFromTemplates(CFAllocatorRef allocator, CFArrayRef tmplates, CFOptionFlags options, CFLocaleRef locale);
549
550 #if (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)
551 // Available for internal use on embedded
552 CF_EXPORT CFNotificationCenterRef CFNotificationCenterGetDistributedCenter(void);
553 #endif
554
555
556 CF_EXTERN_C_END
557
558 #endif /* ! __COREFOUNDATION_CFPRIV__ */
559