2 * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
24 Copyright (c) 1998-2005, Apple, Inc. All rights reserved.
28 APPLE SPI: NOT TO BE USED OUTSIDE APPLE!
31 #if !defined(__COREFOUNDATION_CFPRIV__)
32 #define __COREFOUNDATION_CFPRIV__ 1
35 #include <CoreFoundation/CFBase.h>
36 #include <CoreFoundation/CFArray.h>
37 #include <CoreFoundation/CFString.h>
38 #include <CoreFoundation/CFURL.h>
39 #include <CoreFoundation/CFBundlePriv.h>
42 #if defined(__MACH__) || defined(__WIN32__)
43 #include <CoreFoundation/CFRunLoop.h>
44 #include <CoreFoundation/CFMachPort.h>
45 #include <CoreFoundation/CFSocket.h>
48 #if defined(__cplusplus)
52 CF_EXPORT
intptr_t _CFDoOperation(intptr_t code
, intptr_t subcode1
, intptr_t subcode2
);
54 CF_EXPORT
void _CFRuntimeSetCFMPresent(void *a
);
56 CF_EXPORT
const char *_CFProcessPath(void);
57 CF_EXPORT
const char **_CFGetProcessPath(void);
58 CF_EXPORT
const char **_CFGetProgname(void);
62 CF_EXPORT CFRunLoopRef
CFRunLoopGetMain(void);
63 CF_EXPORT SInt32
CFRunLoopRunSpecific(CFRunLoopRef rl
, CFStringRef modeName
, CFTimeInterval seconds
, Boolean returnAfterSourceHandled
);
65 CF_EXPORT
void _CFRunLoopSetCurrent(CFRunLoopRef rl
);
67 CF_EXPORT Boolean
_CFRunLoopModeContainsMode(CFRunLoopRef rl
, CFStringRef modeName
, CFStringRef candidateContainedName
);
68 CF_EXPORT
void _CFRunLoopAddModeToMode(CFRunLoopRef rl
, CFStringRef modeName
, CFStringRef toModeName
);
69 CF_EXPORT
void _CFRunLoopRemoveModeFromMode(CFRunLoopRef rl
, CFStringRef modeName
, CFStringRef fromModeName
);
70 CF_EXPORT
void _CFRunLoopStopMode(CFRunLoopRef rl
, CFStringRef modeName
);
72 CF_EXPORT CFIndex
CFMachPortGetQueuedMessageCount(CFMachPortRef mp
);
74 CF_EXPORT CFPropertyListRef
_CFURLCopyPropertyListRepresentation(CFURLRef url
);
75 CF_EXPORT CFURLRef
_CFURLCreateFromPropertyListRepresentation(CFAllocatorRef alloc
, CFPropertyListRef pListRepresentation
);
78 CF_EXPORT
void CFPreferencesFlushCaches(void);
80 CF_EXPORT CFTimeInterval
_CFTimeZoneGetDSTOffset(CFTimeZoneRef tz
, CFAbsoluteTime at
);
81 CF_EXPORT CFAbsoluteTime
_CFTimeZoneGetNextDSTSwitch(CFTimeZoneRef tz
, CFAbsoluteTime at
);
83 #if !defined(__WIN32__)
86 Boolean
_CFGetFSSpecFromURL(CFAllocatorRef alloc
, CFURLRef url
, struct FSSpec
*spec
);
89 CFURLRef
_CFCreateURLFromFSSpec(CFAllocatorRef alloc
, const struct FSSpec
*voidspec
, Boolean isDirectory
);
92 #if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
94 kCFURLComponentDecompositionNonHierarchical
,
95 kCFURLComponentDecompositionRFC1808
, /* use this for RFC 1738 decompositions as well */
96 kCFURLComponentDecompositionRFC2396
97 } CFURLComponentDecomposition
;
101 CFStringRef schemeSpecific
;
102 } CFURLComponentsNonHierarchical
;
107 CFStringRef password
;
109 CFIndex port
; /* kCFNotFound means ignore/omit */
110 CFArrayRef pathComponents
;
111 CFStringRef parameterString
;
113 CFStringRef fragment
;
115 } CFURLComponentsRFC1808
;
120 /* if the registered name form of the net location is used, userinfo is NULL, port is kCFNotFound, and host is the entire registered name. */
121 CFStringRef userinfo
;
125 CFArrayRef pathComponents
;
127 CFStringRef fragment
;
129 } CFURLComponentsRFC2396
;
131 /* 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 */
133 Boolean
_CFURLCopyComponents(CFURLRef url
, CFURLComponentDecomposition decompositionType
, void *components
);
135 /* Creates and returns the URL described by components; components should point to the CFURLComponents struct defined above that matches decompositionType. */
137 CFURLRef
_CFURLCreateFromComponents(CFAllocatorRef alloc
, CFURLComponentDecomposition decompositionType
, const void *components
);
138 #define CFURLCopyComponents _CFURLCopyComponents
139 #define CFURLCreateFromComponents _CFURLCreateFromComponents
143 CF_EXPORT Boolean
_CFStringGetFileSystemRepresentation(CFStringRef string
, UInt8
*buffer
, CFIndex maxBufLen
);
145 /* If this is publicized, we might need to create a GetBytesPtr type function as well. */
146 CF_EXPORT CFStringRef
_CFStringCreateWithBytesNoCopy(CFAllocatorRef alloc
, const UInt8
*bytes
, CFIndex numBytes
, CFStringEncoding encoding
, Boolean externalFormat
, CFAllocatorRef contentsDeallocator
);
148 /* These return NULL on MacOS 8 */
150 CFStringRef
CFGetUserName(void);
153 CFURLRef
CFCopyHomeDirectoryURLForUser(CFStringRef uName
); /* Pass NULL for the current user's home directory */
156 CFCopySearchPathForDirectoriesInDomains returns the various
157 standard system directories where apps, resources, etc get
158 installed. Because queries can return multiple directories,
159 you get back a CFArray (which you should free when done) of
160 CFStrings. The directories are returned in search path order;
161 that is, the first place to look is returned first. This API
162 may return directories that do not exist yet. If NSUserDomain
163 is included in a query, then the results will contain "~" to
164 refer to the user's directory. Specify expandTilde to expand
165 this to the current user's home. Some calls might return no
167 ??? On MacOS 8 this function currently returns an empty array.
170 kCFApplicationDirectory
= 1, /* supported applications (Applications) */
171 kCFDemoApplicationDirectory
, /* unsupported applications, demonstration versions (Demos) */
172 kCFDeveloperApplicationDirectory
, /* developer applications (Developer/Applications) */
173 kCFAdminApplicationDirectory
, /* system and network administration applications (Administration) */
174 kCFLibraryDirectory
, /* various user-visible documentation, support, and configuration files, resources (Library) */
175 kCFDeveloperDirectory
, /* developer resources (Developer) */
176 kCFUserDirectory
, /* user home directories (Users) */
177 kCFDocumentationDirectory
, /* documentation (Documentation) */
178 kCFDocumentDirectory
, /* documents (Library/Documents) */
179 kCFAllApplicationsDirectory
= 100, /* all directories where applications can occur (ie Applications, Demos, Administration, Developer/Applications) */
180 kCFAllLibrariesDirectory
= 101 /* all directories where resources can occur (Library, Developer) */
181 } CFSearchPathDirectory
;
184 kCFUserDomainMask
= 1, /* user's home directory --- place to install user's personal items (~) */
185 kCFLocalDomainMask
= 2, /* local to the current machine --- place to install items available to everyone on this machine (/Local) */
186 kCFNetworkDomainMask
= 4, /* publically available location in the local area network --- place to install items available on the network (/Network) */
187 kCFSystemDomainMask
= 8, /* provided by Apple, unmodifiable (/System) */
188 kCFAllDomainsMask
= 0x0ffff /* all domains: all of the above and more, future items */
189 } CFSearchPathDomainMask
;
192 CFArrayRef
CFCopySearchPathForDirectoriesInDomains(CFSearchPathDirectory directory
, CFSearchPathDomainMask domainMask
, Boolean expandTilde
);
195 CF_EXPORT
const CFStringRef kCFFileURLExists
;
196 CF_EXPORT
const CFStringRef kCFFileURLPOSIXMode
;
197 CF_EXPORT
const CFStringRef kCFFileURLSize
;
198 CF_EXPORT
const CFStringRef kCFFileURLDirectoryContents
;
199 CF_EXPORT
const CFStringRef kCFFileURLLastModificationTime
;
200 CF_EXPORT
const CFStringRef kCFHTTPURLStatusCode
;
201 CF_EXPORT
const CFStringRef kCFHTTPURLStatusLine
;
204 /* System Version file access */
205 CF_EXPORT CFStringRef
CFCopySystemVersionString(void); // Human-readable string containing both marketing and build version, should be API'd
206 CF_EXPORT CFDictionaryRef
_CFCopySystemVersionDictionary(void);
207 CF_EXPORT CFDictionaryRef
_CFCopyServerVersionDictionary(void);
208 CF_EXPORT
const CFStringRef _kCFSystemVersionProductNameKey
;
209 CF_EXPORT
const CFStringRef _kCFSystemVersionProductCopyrightKey
;
210 CF_EXPORT
const CFStringRef _kCFSystemVersionProductVersionKey
;
211 CF_EXPORT
const CFStringRef _kCFSystemVersionProductVersionExtraKey
;
212 CF_EXPORT
const CFStringRef _kCFSystemVersionProductUserVisibleVersionKey
; // For loginwindow; see 2987512
213 CF_EXPORT
const CFStringRef _kCFSystemVersionBuildVersionKey
;
214 CF_EXPORT
const CFStringRef _kCFSystemVersionProductVersionStringKey
; // Localized string for the string "Version"
215 CF_EXPORT
const CFStringRef _kCFSystemVersionBuildStringKey
; // Localized string for the string "Build"
218 kCFStringGramphemeCluster
= 1, /* Unicode Grapheme Cluster (not different from kCFStringComposedCharacterCluster right now) */
219 kCFStringComposedCharacterCluster
= 2, /* Compose all non-base (including spacing marks) */
220 kCFStringCursorMovementCluster
= 3, /* Cluster suitable for cursor movements */
221 kCFStringBackwardDeletionCluster
= 4 /* Cluster suitable for backward deletion */
222 } CFStringCharacterClusterType
;
224 CF_EXPORT CFRange
CFStringGetRangeOfCharacterClusterAtIndex(CFStringRef string
, CFIndex charIndex
, CFStringCharacterClusterType type
);
227 kCFCompareDiacriticsInsensitive
= (1 << 28),
228 kCFCompareWidthInsensitive
= (1 << 29),
231 /* CFStringEncoding SPI */
232 /* When set, CF encoding conversion engine keeps ASCII compatibility. (i.e. ASCII backslash <-> Unicode backslash in MacJapanese */
233 CF_EXPORT
void _CFStringEncodingSetForceASCIICompatibility(Boolean flag
);
235 #if defined(CF_INLINE)
236 CF_INLINE
const UniChar
*CFStringGetCharactersPtrFromInlineBuffer(CFStringInlineBuffer
*buf
, CFRange desiredRange
) {
237 if ((desiredRange
.location
< 0) || ((desiredRange
.location
+ desiredRange
.length
) > buf
->rangeToBuffer
.length
)) return NULL
;
239 if (buf
->directBuffer
) {
240 return buf
->directBuffer
+ buf
->rangeToBuffer
.location
+ desiredRange
.location
;
242 if (desiredRange
.length
> __kCFStringInlineBufferLength
) return NULL
;
244 if (((desiredRange
.location
+ desiredRange
.length
) > buf
->bufferedRangeEnd
) || (desiredRange
.location
< buf
->bufferedRangeStart
)) {
245 buf
->bufferedRangeStart
= desiredRange
.location
;
246 buf
->bufferedRangeEnd
= buf
->bufferedRangeStart
+ __kCFStringInlineBufferLength
;
247 if (buf
->bufferedRangeEnd
> buf
->rangeToBuffer
.length
) buf
->bufferedRangeEnd
= buf
->rangeToBuffer
.length
;
248 CFStringGetCharacters(buf
->theString
, CFRangeMake(buf
->rangeToBuffer
.location
+ buf
->bufferedRangeStart
, buf
->bufferedRangeEnd
- buf
->bufferedRangeStart
), buf
->buffer
);
251 return buf
->buffer
+ (desiredRange
.location
- buf
->bufferedRangeStart
);
255 CF_INLINE
void CFStringGetCharactersFromInlineBuffer(CFStringInlineBuffer
*buf
, CFRange desiredRange
, UniChar
*outBuf
) {
256 if (buf
->directBuffer
) {
257 memmove(outBuf
, buf
->directBuffer
+ buf
->rangeToBuffer
.location
+ desiredRange
.location
, desiredRange
.length
* sizeof(UniChar
));
259 if ((desiredRange
.location
>= buf
->bufferedRangeStart
) && (desiredRange
.location
< buf
->bufferedRangeEnd
)) {
260 int bufLen
= desiredRange
.length
;
262 if (bufLen
> (buf
->bufferedRangeEnd
- desiredRange
.location
)) bufLen
= (buf
->bufferedRangeEnd
- desiredRange
.location
);
264 memmove(outBuf
, buf
->buffer
+ (desiredRange
.location
- buf
->bufferedRangeStart
), bufLen
* sizeof(UniChar
));
265 outBuf
+= bufLen
; desiredRange
.location
+= bufLen
; desiredRange
.length
-= bufLen
;
267 int desiredRangeMax
= (desiredRange
.location
+ desiredRange
.length
);
269 if ((desiredRangeMax
> buf
->bufferedRangeStart
) && (desiredRangeMax
< buf
->bufferedRangeEnd
)) {
270 desiredRange
.length
= (buf
->bufferedRangeStart
- desiredRange
.location
);
271 memmove(outBuf
+ desiredRange
.length
, buf
->buffer
, (desiredRangeMax
- buf
->bufferedRangeStart
) * sizeof(UniChar
));
275 if (desiredRange
.length
> 0) CFStringGetCharacters(buf
->theString
, CFRangeMake(buf
->rangeToBuffer
.location
+ desiredRange
.location
, desiredRange
.length
), outBuf
);
280 #define CFStringGetCharactersPtrFromInlineBuffer(buf, desiredRange) ((buf)->directBuffer ? (buf)->directBuffer + (buf)->rangeToBuffer.location + desiredRange.location : NULL)
282 #define CFStringGetCharactersFromInlineBuffer(buf, desiredRange, outBuf) \
283 if (buf->directBuffer) memmove(outBuf, (buf)->directBuffer + (buf)->rangeToBuffer.location + desiredRange.location, desiredRange.length * sizeof(UniChar)); \
284 else CFStringGetCharacters((buf)->theString, CFRangeMake((buf)->rangeToBuffer.location + desiredRange.location, desiredRange.length), outBuf);
286 #endif /* CF_INLINE */
288 #if defined(__cplusplus)
292 #endif /* ! __COREFOUNDATION_CFPRIV__ */