]> git.saurik.com Git - apple/cf.git/blob - Base.subproj/CFPriv.h
CF-299.33.tar.gz
[apple/cf.git] / Base.subproj / CFPriv.h
1 /*
2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /* CFPriv.h
26 Copyright (c) 1998-2003, Apple, Inc. All rights reserved.
27 */
28
29 /*
30 APPLE SPI: NOT TO BE USED OUTSIDE APPLE!
31 */
32
33 #if !defined(__COREFOUNDATION_CFPRIV__)
34 #define __COREFOUNDATION_CFPRIV__ 1
35
36 #include <string.h>
37 #include <CoreFoundation/CFBase.h>
38 #include <CoreFoundation/CFArray.h>
39 #include <CoreFoundation/CFString.h>
40 #include <CoreFoundation/CFURL.h>
41 #if defined(__MACH__)
42 #include <CoreFoundation/CFRunLoop.h>
43 #include <CoreFoundation/CFMachPort.h>
44 #include <CoreFoundation/CFSocket.h>
45 #endif
46
47 #if defined(__cplusplus)
48 extern "C" {
49 #endif
50
51 CF_EXPORT intptr_t _CFDoOperation(intptr_t code, intptr_t subcode1, intptr_t subcode2);
52
53 CF_EXPORT void _CFRuntimeSetCFMPresent(int a);
54
55 CF_EXPORT const char *_CFProcessPath(void);
56
57
58 #if defined(__MACH__)
59 CF_EXPORT CFRunLoopRef CFRunLoopGetMain(void);
60 CF_EXPORT SInt32 CFRunLoopRunSpecific(CFRunLoopRef rl, CFStringRef modeName, CFTimeInterval seconds, Boolean returnAfterSourceHandled);
61
62 CF_EXPORT void _CFRunLoopSetCurrent(CFRunLoopRef rl);
63
64 CF_EXPORT Boolean _CFRunLoopModeContainsMode(CFRunLoopRef rl, CFStringRef modeName, CFStringRef candidateContainedName);
65 CF_EXPORT void _CFRunLoopAddModeToMode(CFRunLoopRef rl, CFStringRef modeName, CFStringRef toModeName);
66 CF_EXPORT void _CFRunLoopRemoveModeFromMode(CFRunLoopRef rl, CFStringRef modeName, CFStringRef fromModeName);
67 CF_EXPORT void _CFRunLoopStopMode(CFRunLoopRef rl, CFStringRef modeName);
68
69 CF_EXPORT CFIndex CFMachPortGetQueuedMessageCount(CFMachPortRef mp);
70
71 CF_EXPORT CFPropertyListRef _CFURLCopyPropertyListRepresentation(CFURLRef url);
72 CF_EXPORT CFURLRef _CFURLCreateFromPropertyListRepresentation(CFAllocatorRef alloc, CFPropertyListRef pListRepresentation);
73 #endif /* __MACH__ */
74
75
76 #if !defined(__WIN32__)
77 struct FSSpec;
78 CF_EXPORT
79 Boolean _CFGetFSSpecFromURL(CFAllocatorRef alloc, CFURLRef url, struct FSSpec *spec);
80
81 CF_EXPORT
82 CFURLRef _CFCreateURLFromFSSpec(CFAllocatorRef alloc, const struct FSSpec *voidspec, Boolean isDirectory);
83 #endif
84
85 #if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED
86 typedef enum {
87 kCFURLComponentDecompositionNonHierarchical,
88 kCFURLComponentDecompositionRFC1808, /* use this for RFC 1738 decompositions as well */
89 kCFURLComponentDecompositionRFC2396
90 } CFURLComponentDecomposition;
91
92 typedef struct {
93 CFStringRef scheme;
94 CFStringRef schemeSpecific;
95 } CFURLComponentsNonHierarchical;
96
97 typedef struct {
98 CFStringRef scheme;
99 CFStringRef user;
100 CFStringRef password;
101 CFStringRef host;
102 CFIndex port; /* kCFNotFound means ignore/omit */
103 CFArrayRef pathComponents;
104 CFStringRef parameterString;
105 CFStringRef query;
106 CFStringRef fragment;
107 CFURLRef baseURL;
108 } CFURLComponentsRFC1808;
109
110 typedef struct {
111 CFStringRef scheme;
112
113 /* if the registered name form of the net location is used, userinfo is NULL, port is kCFNotFound, and host is the entire registered name. */
114 CFStringRef userinfo;
115 CFStringRef host;
116 CFIndex port;
117
118 CFArrayRef pathComponents;
119 CFStringRef query;
120 CFStringRef fragment;
121 CFURLRef baseURL;
122 } CFURLComponentsRFC2396;
123
124 /* 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 */
125 CF_EXPORT
126 Boolean _CFURLCopyComponents(CFURLRef url, CFURLComponentDecomposition decompositionType, void *components);
127
128 /* Creates and returns the URL described by components; components should point to the CFURLComponents struct defined above that matches decompositionType. */
129 CF_EXPORT
130 CFURLRef _CFURLCreateFromComponents(CFAllocatorRef alloc, CFURLComponentDecomposition decompositionType, const void *components);
131 #define CFURLCopyComponents _CFURLCopyComponents
132 #define CFURLCreateFromComponents _CFURLCreateFromComponents
133 #endif
134
135
136 CF_EXPORT Boolean _CFStringGetFileSystemRepresentation(CFStringRef string, UInt8 *buffer, CFIndex maxBufLen);
137
138 /* If this is publicized, we might need to create a GetBytesPtr type function as well. */
139 CF_EXPORT CFStringRef _CFStringCreateWithBytesNoCopy(CFAllocatorRef alloc, const UInt8 *bytes, CFIndex numBytes, CFStringEncoding encoding, Boolean externalFormat, CFAllocatorRef contentsDeallocator);
140
141 /* These return NULL on MacOS 8 */
142 CF_EXPORT
143 CFStringRef CFGetUserName(void);
144
145 CF_EXPORT
146 CFURLRef CFCopyHomeDirectoryURLForUser(CFStringRef uName); /* Pass NULL for the current user's home directory */
147
148 /*
149 CFCopySearchPathForDirectoriesInDomains returns the various
150 standard system directories where apps, resources, etc get
151 installed. Because queries can return multiple directories,
152 you get back a CFArray (which you should free when done) of
153 CFStrings. The directories are returned in search path order;
154 that is, the first place to look is returned first. This API
155 may return directories that do not exist yet. If NSUserDomain
156 is included in a query, then the results will contain "~" to
157 refer to the user's directory. Specify expandTilde to expand
158 this to the current user's home. Some calls might return no
159 directories!
160 ??? On MacOS 8 this function currently returns an empty array.
161 */
162 typedef enum {
163 kCFApplicationDirectory = 1, /* supported applications (Applications) */
164 kCFDemoApplicationDirectory, /* unsupported applications, demonstration versions (Demos) */
165 kCFDeveloperApplicationDirectory, /* developer applications (Developer/Applications) */
166 kCFAdminApplicationDirectory, /* system and network administration applications (Administration) */
167 kCFLibraryDirectory, /* various user-visible documentation, support, and configuration files, resources (Library) */
168 kCFDeveloperDirectory, /* developer resources (Developer) */
169 kCFUserDirectory, /* user home directories (Users) */
170 kCFDocumentationDirectory, /* documentation (Documentation) */
171 kCFDocumentDirectory, /* documents (Library/Documents) */
172 kCFAllApplicationsDirectory = 100, /* all directories where applications can occur (ie Applications, Demos, Administration, Developer/Applications) */
173 kCFAllLibrariesDirectory = 101 /* all directories where resources can occur (Library, Developer) */
174 } CFSearchPathDirectory;
175
176 typedef enum {
177 kCFUserDomainMask = 1, /* user's home directory --- place to install user's personal items (~) */
178 kCFLocalDomainMask = 2, /* local to the current machine --- place to install items available to everyone on this machine (/Local) */
179 kCFNetworkDomainMask = 4, /* publically available location in the local area network --- place to install items available on the network (/Network) */
180 kCFSystemDomainMask = 8, /* provided by Apple, unmodifiable (/System) */
181 kCFAllDomainsMask = 0x0ffff /* all domains: all of the above and more, future items */
182 } CFSearchPathDomainMask;
183
184 CF_EXPORT
185 CFArrayRef CFCopySearchPathForDirectoriesInDomains(CFSearchPathDirectory directory, CFSearchPathDomainMask domainMask, Boolean expandTilde);
186
187 /* Obsolete keys */
188 CF_EXPORT const CFStringRef kCFFileURLExists;
189 CF_EXPORT const CFStringRef kCFFileURLPOSIXMode;
190 CF_EXPORT const CFStringRef kCFFileURLSize;
191 CF_EXPORT const CFStringRef kCFFileURLDirectoryContents;
192 CF_EXPORT const CFStringRef kCFFileURLLastModificationTime;
193 CF_EXPORT const CFStringRef kCFHTTPURLStatusCode;
194 CF_EXPORT const CFStringRef kCFHTTPURLStatusLine;
195
196
197 /* System Version file access - the results of these calls are cached, and should be fast after the first call */
198 CF_EXPORT CFStringRef CFCopySystemVersionString(void); // Human-readable string containing both marketing and build version, should be API'd
199 CF_EXPORT CFDictionaryRef _CFCopySystemVersionDictionary(void);
200 CF_EXPORT CFDictionaryRef _CFCopyServerVersionDictionary(void);
201 CF_EXPORT const CFStringRef _kCFSystemVersionProductNameKey;
202 CF_EXPORT const CFStringRef _kCFSystemVersionProductCopyrightKey;
203 CF_EXPORT const CFStringRef _kCFSystemVersionProductVersionKey;
204 CF_EXPORT const CFStringRef _kCFSystemVersionProductVersionExtraKey;
205 CF_EXPORT const CFStringRef _kCFSystemVersionProductUserVisibleVersionKey; // For loginwindow; see 2987512
206 CF_EXPORT const CFStringRef _kCFSystemVersionBuildVersionKey;
207 CF_EXPORT const CFStringRef _kCFSystemVersionProductVersionStringKey; // Localized string for the string "Version"
208 CF_EXPORT const CFStringRef _kCFSystemVersionBuildStringKey; // Localized string for the string "Build"
209
210 typedef enum {
211 kCFStringGramphemeCluster = 1, /* Unicode Grapheme Cluster (not different from kCFStringComposedCharacterCluster right now) */
212 kCFStringComposedCharacterCluster = 2, /* Compose all non-base (including spacing marks) */
213 kCFStringCursorMovementCluster = 3, /* Cluster suitable for cursor movements */
214 kCFStringBackwardDeletionCluster = 4 /* Cluster suitable for backward deletion */
215 } CFStringCharacterClusterType;
216
217 CF_EXPORT CFRange CFStringGetRangeOfCharacterClusterAtIndex(CFStringRef string, CFIndex charIndex, CFStringCharacterClusterType type);
218
219
220 /* CFStringEncoding SPI */
221 /* When set, CF encoding conversion engine keeps ASCII compatibility. (i.e. ASCII backslash <-> Unicode backslash in MacJapanese */
222 CF_EXPORT void _CFStringEncodingSetForceASCIICompatibility(Boolean flag);
223
224 #if defined(CF_INLINE)
225 CF_INLINE const UniChar *CFStringGetCharactersPtrFromInlineBuffer(CFStringInlineBuffer *buf, CFRange desiredRange) {
226 if ((desiredRange.location < 0) || ((desiredRange.location + desiredRange.length) > buf->rangeToBuffer.length)) return NULL;
227
228 if (buf->directBuffer) {
229 return buf->directBuffer + buf->rangeToBuffer.location + desiredRange.location;
230 } else {
231 if (desiredRange.length > __kCFStringInlineBufferLength) return NULL;
232
233 if (((desiredRange.location + desiredRange.length) > buf->bufferedRangeEnd) || (desiredRange.location < buf->bufferedRangeStart)) {
234 buf->bufferedRangeStart = desiredRange.location;
235 buf->bufferedRangeEnd = buf->bufferedRangeStart + __kCFStringInlineBufferLength;
236 if (buf->bufferedRangeEnd > buf->rangeToBuffer.length) buf->bufferedRangeEnd = buf->rangeToBuffer.length;
237 CFStringGetCharacters(buf->theString, CFRangeMake(buf->rangeToBuffer.location + buf->bufferedRangeStart, buf->bufferedRangeEnd - buf->bufferedRangeStart), buf->buffer);
238 }
239
240 return buf->buffer + (desiredRange.location - buf->bufferedRangeStart);
241 }
242 }
243
244 CF_INLINE void CFStringGetCharactersFromInlineBuffer(CFStringInlineBuffer *buf, CFRange desiredRange, UniChar *outBuf) {
245 if (buf->directBuffer) {
246 memmove(outBuf, buf->directBuffer + buf->rangeToBuffer.location + desiredRange.location, desiredRange.length * sizeof(UniChar));
247 } else {
248 if ((desiredRange.location >= buf->bufferedRangeStart) && (desiredRange.location < buf->bufferedRangeEnd)) {
249 int bufLen = desiredRange.length;
250
251 if (bufLen > (buf->bufferedRangeEnd - desiredRange.location)) bufLen = (buf->bufferedRangeEnd - desiredRange.location);
252
253 memmove(outBuf, buf->buffer + (desiredRange.location - buf->bufferedRangeStart), bufLen * sizeof(UniChar));
254 outBuf += bufLen; desiredRange.location += bufLen; desiredRange.length -= bufLen;
255 } else {
256 int desiredRangeMax = (desiredRange.location + desiredRange.length);
257
258 if ((desiredRangeMax > buf->bufferedRangeStart) && (desiredRangeMax < buf->bufferedRangeEnd)) {
259 desiredRange.length = (buf->bufferedRangeStart - desiredRange.location);
260 memmove(outBuf + desiredRange.length, buf->buffer, (desiredRangeMax - buf->bufferedRangeStart) * sizeof(UniChar));
261 }
262 }
263
264 if (desiredRange.length > 0) CFStringGetCharacters(buf->theString, CFRangeMake(buf->rangeToBuffer.location + desiredRange.location, desiredRange.length), outBuf);
265 }
266 }
267
268 #else
269 #define CFStringGetCharactersPtrFromInlineBuffer(buf, desiredRange) ((buf)->directBuffer ? (buf)->directBuffer + (buf)->rangeToBuffer.location + desiredRange.location : NULL)
270
271 #define CFStringGetCharactersFromInlineBuffer(buf, desiredRange, outBuf) \
272 if (buf->directBuffer) memmove(outBuf, (buf)->directBuffer + (buf)->rangeToBuffer.location + desiredRange.location, desiredRange.length * sizeof(UniChar)); \
273 else CFStringGetCharacters((buf)->theString, CFRangeMake((buf)->rangeToBuffer.location + desiredRange.location, desiredRange.length), outBuf);
274
275 #endif /* CF_INLINE */
276
277 #if defined(__cplusplus)
278 }
279 #endif
280
281 #endif /* ! __COREFOUNDATION_CFPRIV__ */
282