1 {	CFURLAccess.h
2 	Copyright (c) 1998-2013, Apple Inc. All rights reserved.
3 
4         CFURLAccess is deprecated as of Mac OS X 10.9 and iOS 7.0. The suggested replacement for URLs with network schemes (http, https, ftp, data) is the NSURLConnection class. The suggested replacement for URLs with the file scheme are the foundation classes NSFileManager, NSFileHandle and NSURL, or the CoreFoundation classes CFStream and CFURL.
5 }
6 {
7     Modified for use with Free Pascal
8     Version 308
9     Please report any bugs to <gpc@microbizz.nl>
10 }
11 
12 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
13 {$mode macpas}
14 {$modeswitch cblocks}
15 {$packenum 1}
16 {$macro on}
17 {$inline on}
18 {$calling mwpascal}
19 
20 unit CFURLAccess;
21 interface
22 {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
23 {$setc GAP_INTERFACES_VERSION := $0308}
24 
25 {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
26     {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
27 {$endc}
28 
29 {$ifc defined CPUPOWERPC and defined CPUI386}
30 	{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
31 {$endc}
32 {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
33 	{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
34 {$endc}
35 
36 {$ifc not defined __ppc__ and defined CPUPOWERPC32}
37 	{$setc __ppc__ := 1}
38 {$elsec}
39 	{$setc __ppc__ := 0}
40 {$endc}
41 {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
42 	{$setc __ppc64__ := 1}
43 {$elsec}
44 	{$setc __ppc64__ := 0}
45 {$endc}
46 {$ifc not defined __i386__ and defined CPUI386}
47 	{$setc __i386__ := 1}
48 {$elsec}
49 	{$setc __i386__ := 0}
50 {$endc}
51 {$ifc not defined __x86_64__ and defined CPUX86_64}
52 	{$setc __x86_64__ := 1}
53 {$elsec}
54 	{$setc __x86_64__ := 0}
55 {$endc}
56 {$ifc not defined __arm__ and defined CPUARM}
57 	{$setc __arm__ := 1}
58 {$elsec}
59 	{$setc __arm__ := 0}
60 {$endc}
61 {$ifc not defined __arm64__ and defined CPUAARCH64}
62   {$setc __arm64__ := 1}
63 {$elsec}
64   {$setc __arm64__ := 0}
65 {$endc}
66 
67 {$ifc defined cpu64}
68   {$setc __LP64__ := 1}
69 {$elsec}
70   {$setc __LP64__ := 0}
71 {$endc}
72 
73 
74 {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
75 	{$error Conflicting definitions for __ppc__ and __i386__}
76 {$endc}
77 
78 {$ifc defined __ppc__ and __ppc__}
79 	{$setc TARGET_CPU_PPC := TRUE}
80 	{$setc TARGET_CPU_PPC64 := FALSE}
81 	{$setc TARGET_CPU_X86 := FALSE}
82 	{$setc TARGET_CPU_X86_64 := FALSE}
83 	{$setc TARGET_CPU_ARM := FALSE}
84 	{$setc TARGET_CPU_ARM64 := FALSE}
85 	{$setc TARGET_OS_MAC := TRUE}
86 	{$setc TARGET_OS_IPHONE := FALSE}
87 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
88 	{$setc TARGET_OS_EMBEDDED := FALSE}
89 {$elifc defined __ppc64__ and __ppc64__}
90 	{$setc TARGET_CPU_PPC := FALSE}
91 	{$setc TARGET_CPU_PPC64 := TRUE}
92 	{$setc TARGET_CPU_X86 := FALSE}
93 	{$setc TARGET_CPU_X86_64 := FALSE}
94 	{$setc TARGET_CPU_ARM := FALSE}
95 	{$setc TARGET_CPU_ARM64 := FALSE}
96 	{$setc TARGET_OS_MAC := TRUE}
97 	{$setc TARGET_OS_IPHONE := FALSE}
98 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
99 	{$setc TARGET_OS_EMBEDDED := FALSE}
100 {$elifc defined __i386__ and __i386__}
101 	{$setc TARGET_CPU_PPC := FALSE}
102 	{$setc TARGET_CPU_PPC64 := FALSE}
103 	{$setc TARGET_CPU_X86 := TRUE}
104 	{$setc TARGET_CPU_X86_64 := FALSE}
105 	{$setc TARGET_CPU_ARM := FALSE}
106 	{$setc TARGET_CPU_ARM64 := FALSE}
107 {$ifc defined iphonesim}
108  	{$setc TARGET_OS_MAC := FALSE}
109 	{$setc TARGET_OS_IPHONE := TRUE}
110 	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
111 {$elsec}
112 	{$setc TARGET_OS_MAC := TRUE}
113 	{$setc TARGET_OS_IPHONE := FALSE}
114 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
115 {$endc}
116 	{$setc TARGET_OS_EMBEDDED := FALSE}
117 {$elifc defined __x86_64__ and __x86_64__}
118 	{$setc TARGET_CPU_PPC := FALSE}
119 	{$setc TARGET_CPU_PPC64 := FALSE}
120 	{$setc TARGET_CPU_X86 := FALSE}
121 	{$setc TARGET_CPU_X86_64 := TRUE}
122 	{$setc TARGET_CPU_ARM := FALSE}
123 	{$setc TARGET_CPU_ARM64 := FALSE}
124 {$ifc defined iphonesim}
125  	{$setc TARGET_OS_MAC := FALSE}
126 	{$setc TARGET_OS_IPHONE := TRUE}
127 	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
128 {$elsec}
129 	{$setc TARGET_OS_MAC := TRUE}
130 	{$setc TARGET_OS_IPHONE := FALSE}
131 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
132 {$endc}
133 	{$setc TARGET_OS_EMBEDDED := FALSE}
134 {$elifc defined __arm__ and __arm__}
135 	{$setc TARGET_CPU_PPC := FALSE}
136 	{$setc TARGET_CPU_PPC64 := FALSE}
137 	{$setc TARGET_CPU_X86 := FALSE}
138 	{$setc TARGET_CPU_X86_64 := FALSE}
139 	{$setc TARGET_CPU_ARM := TRUE}
140 	{$setc TARGET_CPU_ARM64 := FALSE}
141 	{$setc TARGET_OS_MAC := FALSE}
142 	{$setc TARGET_OS_IPHONE := TRUE}
143 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
144 	{$setc TARGET_OS_EMBEDDED := TRUE}
145 {$elifc defined __arm64__ and __arm64__}
146 	{$setc TARGET_CPU_PPC := FALSE}
147 	{$setc TARGET_CPU_PPC64 := FALSE}
148 	{$setc TARGET_CPU_X86 := FALSE}
149 	{$setc TARGET_CPU_X86_64 := FALSE}
150 	{$setc TARGET_CPU_ARM := FALSE}
151 	{$setc TARGET_CPU_ARM64 := TRUE}
152 {$ifc defined ios}
153 	{$setc TARGET_OS_MAC := FALSE}
154 	{$setc TARGET_OS_IPHONE := TRUE}
155 	{$setc TARGET_OS_EMBEDDED := TRUE}
156 {$elsec}
157 	{$setc TARGET_OS_MAC := TRUE}
158 	{$setc TARGET_OS_IPHONE := FALSE}
159 	{$setc TARGET_OS_EMBEDDED := FALSE}
160 {$endc}
161 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
162 {$elsec}
163 	{$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
164 {$endc}
165 
166 {$ifc defined __LP64__ and __LP64__ }
167   {$setc TARGET_CPU_64 := TRUE}
168 {$elsec}
169   {$setc TARGET_CPU_64 := FALSE}
170 {$endc}
171 
172 {$ifc defined FPC_BIG_ENDIAN}
173 	{$setc TARGET_RT_BIG_ENDIAN := TRUE}
174 	{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
175 {$elifc defined FPC_LITTLE_ENDIAN}
176 	{$setc TARGET_RT_BIG_ENDIAN := FALSE}
177 	{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
178 {$elsec}
179 	{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
180 {$endc}
181 {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
182 {$setc CALL_NOT_IN_CARBON := FALSE}
183 {$setc OLDROUTINENAMES := FALSE}
184 {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
185 {$setc OPAQUE_UPP_TYPES := TRUE}
186 {$setc OTCARBONAPPLICATION := TRUE}
187 {$setc OTKERNEL := FALSE}
188 {$setc PM_USE_SESSION_APIS := TRUE}
189 {$setc TARGET_API_MAC_CARBON := TRUE}
190 {$setc TARGET_API_MAC_OS8 := FALSE}
191 {$setc TARGET_API_MAC_OSX := TRUE}
192 {$setc TARGET_CARBON := TRUE}
193 {$setc TARGET_CPU_68K := FALSE}
194 {$setc TARGET_CPU_MIPS := FALSE}
195 {$setc TARGET_CPU_SPARC := FALSE}
196 {$setc TARGET_OS_UNIX := FALSE}
197 {$setc TARGET_OS_WIN32 := FALSE}
198 {$setc TARGET_RT_MAC_68881 := FALSE}
199 {$setc TARGET_RT_MAC_CFM := FALSE}
200 {$setc TARGET_RT_MAC_MACHO := TRUE}
201 {$setc TYPED_FUNCTION_POINTERS := TRUE}
202 {$setc TYPE_BOOL := FALSE}
203 {$setc TYPE_EXTENDED := FALSE}
204 {$setc TYPE_LONGLONG := TRUE}
205 uses MacTypes,CFBase,CFArray,CFData,CFDictionary,CFString,CFURL;
206 {$endc} {not MACOSALLINCLUDE}
207 
208 {$ALIGN POWER}
209 
210 
211 { Attempts to read the data and properties for the given URL.  If
212 only interested in one of the resourceData and properties, pass NULL
213 for the other.  If properties is non-NULL and desiredProperties is
214 NULL, then all properties are fetched.  Returns success or failure;
215 note that as much work as possible is done even if false is returned.
216 So for instance if one property is not available, the others are
217 fetched anyway. errorCode is set to 0 on success, and some other
218 value on failure.  If non-NULL, it is the caller 's responsibility
219 to release resourceData and properties.
220 
221     Apple reserves for its use all negative error code values; these
222 values represent errors common to any scheme.  Scheme-specific error
223 codes should be positive, non-zero, and should be used only if one of
224 the predefined Apple error codes does not apply.  Error codes should
225 be publicized and documented with the scheme-specific properties.
226 
227 NOTE: When asking for the resource data, this call will allocate the entire
228 resource in memory. This can be very expensive, depending on the size of the
229 resource (file). Please use CFStream or other techniques if you are downloading
230 large files.
231 
232 }
233 { Deprecated -- see top of this file for suggested replacement classes }
CFURLCreateDataAndPropertiesFromResourcenull234 function CFURLCreateDataAndPropertiesFromResource( alloc: CFAllocatorRef; url: CFURLRef; resourceData: CFDataRefPtr; properties: CFDictionaryRefPtr; desiredProperties: CFArrayRef; var errorCode: SInt32 ): Boolean; external name '_CFURLCreateDataAndPropertiesFromResource';
235 (* CF_DEPRECATED(10_0, 10_9, 2_0, 7_0) *)
236 
237 { Attempts to write the given data and properties to the given URL.
238 If dataToWrite is NULL, only properties are written out (use
239 CFURLDestroyResource() to delete a resource).  Properties not present
240 in propertiesToWrite are left unchanged, hence if propertiesToWrite
241 is NULL or empty, the URL's properties are not changed at all.
242 Returns success or failure; errorCode is set as for
243 CFURLCreateDataAndPropertiesFromResource(), above.
244 }
245 { Deprecated -- see top of this file for suggested replacement classes }
CFURLWriteDataAndPropertiesToResourcenull246 function CFURLWriteDataAndPropertiesToResource( url: CFURLRef; dataToWrite: CFDataRef; propertiesToWrite: CFDictionaryRef; var errorCode: SInt32 ): Boolean; external name '_CFURLWriteDataAndPropertiesToResource';
247 (* CF_DEPRECATED(10_0, 10_9, 2_0, 7_0) *)
248 
249 { Destroys the resource indicated by url.
250 Returns success or failure; errorCode set as above.
251 }
252 { Deprecated -- see top of this file for suggested replacement classes }
CFURLDestroyResourcenull253 function CFURLDestroyResource( url: CFURLRef; var errorCode: SInt32 ): Boolean; external name '_CFURLDestroyResource';
254 (* CF_DEPRECATED(10_0, 10_9, 2_0, 7_0) *)
255 
256 { Convenience method which calls through to CFURLCreateDataAndPropertiesFromResource().
257 Returns NULL on error and sets errorCode accordingly.
258 }
259 { Deprecated -- see top of this file for suggested replacement classes }
CFURLCreatePropertyFromResourcenull260 function CFURLCreatePropertyFromResource( alloc: CFAllocatorRef; url: CFURLRef; proprty: CFStringRef; var errorCode: SInt32 ): CFTypeRef; external name '_CFURLCreatePropertyFromResource';
261 (* CF_DEPRECATED(10_0, 10_9, 2_0, 7_0) *)
262 
263 
264 { Common error codes (returned only by the older APIs that predate CFError) }
265 type
266 	CFURLError = CFIndex;
267 const
268 	kCFURLUnknownError = -10; (* CF_ENUM_DEPRECATED(10_0, 10_9, 2_0, 7_0) *)
269 	kCFURLUnknownSchemeError = -11; (* CF_ENUM_DEPRECATED(10_0, 10_9, 2_0, 7_0) *)
270 	kCFURLResourceNotFoundError = -12; (* CF_ENUM_DEPRECATED(10_0, 10_9, 2_0, 7_0) *)
271 	kCFURLResourceAccessViolationError = -13; (* CF_ENUM_DEPRECATED(10_0, 10_9, 2_0, 7_0) *)
272 	kCFURLRemoteHostUnavailableError = -14; (* CF_ENUM_DEPRECATED(10_0, 10_9, 2_0, 7_0) *)
273 	kCFURLImproperArgumentsError = -15; (* CF_ENUM_DEPRECATED(10_0, 10_9, 2_0, 7_0) *)
274 	kCFURLUnknownPropertyKeyError = -16; (* CF_ENUM_DEPRECATED(10_0, 10_9, 2_0, 7_0) *)
275 	kCFURLPropertyKeyUnavailableError = -17; (* CF_ENUM_DEPRECATED(10_0, 10_9, 2_0, 7_0) *)
276 	kCFURLTimeoutError = -18; (* CF_ENUM_DEPRECATED(10_0, 10_9, 2_0, 7_0) *)
277 
278 { Older property keys }
279 
280 var kCFURLFileExists: CFStringRef; external name '_kCFURLFileExists'; (* attribute const *)
281 (* CF_DEPRECATED(10_0, 10_9, 2_0, 7_0) *)
282 var kCFURLFileDirectoryContents: CFStringRef; external name '_kCFURLFileDirectoryContents'; (* attribute const *)
283 (* CF_DEPRECATED(10_0, 10_9, 2_0, 7_0) *)
284 var kCFURLFileLength: CFStringRef; external name '_kCFURLFileLength'; (* attribute const *)
285 (* CF_DEPRECATED(10_0, 10_9, 2_0, 7_0) *)
286 var kCFURLFileLastModificationTime: CFStringRef; external name '_kCFURLFileLastModificationTime'; (* attribute const *)
287 (* CF_DEPRECATED(10_0, 10_9, 2_0, 7_0) *)
288 var kCFURLFilePOSIXMode: CFStringRef; external name '_kCFURLFilePOSIXMode'; (* attribute const *)
289 (* CF_DEPRECATED(10_0, 10_9, 2_0, 7_0) *)
290 var kCFURLFileOwnerID: CFStringRef; external name '_kCFURLFileOwnerID'; (* attribute const *)
291 (* CF_DEPRECATED(10_0, 10_9, 2_0, 7_0) *)
292 var kCFURLHTTPStatusCode: CFStringRef; external name '_kCFURLHTTPStatusCode'; (* attribute const *)
293 (* CF_DEPRECATED(10_0, 10_9, 2_0, 7_0) *)
294 var kCFURLHTTPStatusLine: CFStringRef; external name '_kCFURLHTTPStatusLine'; (* attribute const *)
295 (* CF_DEPRECATED(10_0, 10_9, 2_0, 7_0) *)
296 
297 { The value of kCFURLFileExists is a CFBoolean }
298 { The value of kCFURLFileDirectoryContents is a CFArray containing CFURLs.  An empty array means the directory exists, but is empty }
299 { The value of kCFURLFileLength is a CFNumber giving the file's length in bytes }
300 { The value of kCFURLFileLastModificationTime is a CFDate }
301 { The value of kCFURLFilePOSIXMode is a CFNumber as given in stat.h }
302 { The value of kCFURLFileOwnerID is a CFNumber representing the owner's uid }
303 
304 { Properties for the http: scheme.  Except for the common error codes, above, errorCode will be set to the HTTP response status code upon failure.  Any HTTP header name can also be used as a property }
305 { The value of kCFURLHTTPStatusCode is a CFNumber }
306 { The value of kCFURLHTTPStatusLine is a CFString }
307 
308 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
309 
310 end.
311 {$endc} {not MACOSALLINCLUDE}
312