]> git.saurik.com Git - apple/cf.git/blob - Base.subproj/CFPriv.h
CF-368.18.tar.gz
[apple/cf.git] / Base.subproj / CFPriv.h
1 /*
2 * Copyright (c) 2005 Apple Computer, 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 /* CFPriv.h
24 Copyright (c) 1998-2005, Apple, Inc. All rights reserved.
25 */
26
27 /*
28 APPLE SPI: NOT TO BE USED OUTSIDE APPLE!
29 */
30
31 #if !defined(__COREFOUNDATION_CFPRIV__)
32 #define __COREFOUNDATION_CFPRIV__ 1
33
34 #include <string.h>
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>
40
41
42 #if defined(__MACH__) || defined(__WIN32__)
43 #include <CoreFoundation/CFRunLoop.h>
44 #include <CoreFoundation/CFMachPort.h>
45 #include <CoreFoundation/CFSocket.h>
46 #endif
47
48 #if defined(__cplusplus)
49 extern "C" {
50 #endif
51
52 CF_EXPORT intptr_t _CFDoOperation(intptr_t code, intptr_t subcode1, intptr_t subcode2);
53
54 CF_EXPORT void _CFRuntimeSetCFMPresent(void *a);
55
56 CF_EXPORT const char *_CFProcessPath(void);
57 CF_EXPORT const char **_CFGetProcessPath(void);
58 CF_EXPORT const char **_CFGetProgname(void);
59
60
61 #if defined(__MACH__)
62 CF_EXPORT CFRunLoopRef CFRunLoopGetMain(void);
63 CF_EXPORT SInt32 CFRunLoopRunSpecific(CFRunLoopRef rl, CFStringRef modeName, CFTimeInterval seconds, Boolean returnAfterSourceHandled);
64
65 CF_EXPORT void _CFRunLoopSetCurrent(CFRunLoopRef rl);
66
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);
71
72 CF_EXPORT CFIndex CFMachPortGetQueuedMessageCount(CFMachPortRef mp);
73
74 CF_EXPORT CFPropertyListRef _CFURLCopyPropertyListRepresentation(CFURLRef url);
75 CF_EXPORT CFURLRef _CFURLCreateFromPropertyListRepresentation(CFAllocatorRef alloc, CFPropertyListRef pListRepresentation);
76 #endif /* __MACH__ */
77
78 CF_EXPORT void CFPreferencesFlushCaches(void);
79
80 CF_EXPORT CFTimeInterval _CFTimeZoneGetDSTOffset(CFTimeZoneRef tz, CFAbsoluteTime at);
81 CF_EXPORT CFAbsoluteTime _CFTimeZoneGetNextDSTSwitch(CFTimeZoneRef tz, CFAbsoluteTime at);
82
83 #if !defined(__WIN32__)
84 struct FSSpec;
85 CF_EXPORT
86 Boolean _CFGetFSSpecFromURL(CFAllocatorRef alloc, CFURLRef url, struct FSSpec *spec);
87
88 CF_EXPORT
89 CFURLRef _CFCreateURLFromFSSpec(CFAllocatorRef alloc, const struct FSSpec *voidspec, Boolean isDirectory);
90 #endif
91
92 #if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
93 typedef enum {
94 kCFURLComponentDecompositionNonHierarchical,
95 kCFURLComponentDecompositionRFC1808, /* use this for RFC 1738 decompositions as well */
96 kCFURLComponentDecompositionRFC2396
97 } CFURLComponentDecomposition;
98
99 typedef struct {
100 CFStringRef scheme;
101 CFStringRef schemeSpecific;
102 } CFURLComponentsNonHierarchical;
103
104 typedef struct {
105 CFStringRef scheme;
106 CFStringRef user;
107 CFStringRef password;
108 CFStringRef host;
109 CFIndex port; /* kCFNotFound means ignore/omit */
110 CFArrayRef pathComponents;
111 CFStringRef parameterString;
112 CFStringRef query;
113 CFStringRef fragment;
114 CFURLRef baseURL;
115 } CFURLComponentsRFC1808;
116
117 typedef struct {
118 CFStringRef scheme;
119
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;
122 CFStringRef host;
123 CFIndex port;
124
125 CFArrayRef pathComponents;
126 CFStringRef query;
127 CFStringRef fragment;
128 CFURLRef baseURL;
129 } CFURLComponentsRFC2396;
130
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 */
132 CF_EXPORT
133 Boolean _CFURLCopyComponents(CFURLRef url, CFURLComponentDecomposition decompositionType, void *components);
134
135 /* Creates and returns the URL described by components; components should point to the CFURLComponents struct defined above that matches decompositionType. */
136 CF_EXPORT
137 CFURLRef _CFURLCreateFromComponents(CFAllocatorRef alloc, CFURLComponentDecomposition decompositionType, const void *components);
138 #define CFURLCopyComponents _CFURLCopyComponents
139 #define CFURLCreateFromComponents _CFURLCreateFromComponents
140 #endif
141
142
143 CF_EXPORT Boolean _CFStringGetFileSystemRepresentation(CFStringRef string, UInt8 *buffer, CFIndex maxBufLen);
144
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);
147
148 /* These return NULL on MacOS 8 */
149 CF_EXPORT
150 CFStringRef CFGetUserName(void);
151
152 CF_EXPORT
153 CFURLRef CFCopyHomeDirectoryURLForUser(CFStringRef uName); /* Pass NULL for the current user's home directory */
154
155 /*
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
166 directories!
167 ??? On MacOS 8 this function currently returns an empty array.
168 */
169 typedef enum {
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;
182
183 typedef enum {
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;
190
191 CF_EXPORT
192 CFArrayRef CFCopySearchPathForDirectoriesInDomains(CFSearchPathDirectory directory, CFSearchPathDomainMask domainMask, Boolean expandTilde);
193
194 /* Obsolete keys */
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;
202
203
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"
216
217 typedef enum {
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;
223
224 CF_EXPORT CFRange CFStringGetRangeOfCharacterClusterAtIndex(CFStringRef string, CFIndex charIndex, CFStringCharacterClusterType type);
225
226 enum {
227 kCFCompareDiacriticsInsensitive = (1 << 28),
228 kCFCompareWidthInsensitive = (1 << 29),
229 };
230
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);
234
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;
238
239 if (buf->directBuffer) {
240 return buf->directBuffer + buf->rangeToBuffer.location + desiredRange.location;
241 } else {
242 if (desiredRange.length > __kCFStringInlineBufferLength) return NULL;
243
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);
249 }
250
251 return buf->buffer + (desiredRange.location - buf->bufferedRangeStart);
252 }
253 }
254
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));
258 } else {
259 if ((desiredRange.location >= buf->bufferedRangeStart) && (desiredRange.location < buf->bufferedRangeEnd)) {
260 int bufLen = desiredRange.length;
261
262 if (bufLen > (buf->bufferedRangeEnd - desiredRange.location)) bufLen = (buf->bufferedRangeEnd - desiredRange.location);
263
264 memmove(outBuf, buf->buffer + (desiredRange.location - buf->bufferedRangeStart), bufLen * sizeof(UniChar));
265 outBuf += bufLen; desiredRange.location += bufLen; desiredRange.length -= bufLen;
266 } else {
267 int desiredRangeMax = (desiredRange.location + desiredRange.length);
268
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));
272 }
273 }
274
275 if (desiredRange.length > 0) CFStringGetCharacters(buf->theString, CFRangeMake(buf->rangeToBuffer.location + desiredRange.location, desiredRange.length), outBuf);
276 }
277 }
278
279 #else
280 #define CFStringGetCharactersPtrFromInlineBuffer(buf, desiredRange) ((buf)->directBuffer ? (buf)->directBuffer + (buf)->rangeToBuffer.location + desiredRange.location : NULL)
281
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);
285
286 #endif /* CF_INLINE */
287
288 #if defined(__cplusplus)
289 }
290 #endif
291
292 #endif /* ! __COREFOUNDATION_CFPRIV__ */
293