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