1 {	CFPropertyList.h
2 	Copyright (c) 1998-2013, Apple Inc. All rights reserved.
3 }
4 {
5     Modified for use with Free Pascal
6     Version 308
7     Please report any bugs to <gpc@microbizz.nl>
8 }
9 
10 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
11 {$mode macpas}
12 {$modeswitch cblocks}
13 {$packenum 1}
14 {$macro on}
15 {$inline on}
16 {$calling mwpascal}
17 
18 unit CFPropertyList;
19 interface
20 {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
21 {$setc GAP_INTERFACES_VERSION := $0308}
22 
23 {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
24     {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
25 {$endc}
26 
27 {$ifc defined CPUPOWERPC and defined CPUI386}
28 	{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
29 {$endc}
30 {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
31 	{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
32 {$endc}
33 
34 {$ifc not defined __ppc__ and defined CPUPOWERPC32}
35 	{$setc __ppc__ := 1}
36 {$elsec}
37 	{$setc __ppc__ := 0}
38 {$endc}
39 {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
40 	{$setc __ppc64__ := 1}
41 {$elsec}
42 	{$setc __ppc64__ := 0}
43 {$endc}
44 {$ifc not defined __i386__ and defined CPUI386}
45 	{$setc __i386__ := 1}
46 {$elsec}
47 	{$setc __i386__ := 0}
48 {$endc}
49 {$ifc not defined __x86_64__ and defined CPUX86_64}
50 	{$setc __x86_64__ := 1}
51 {$elsec}
52 	{$setc __x86_64__ := 0}
53 {$endc}
54 {$ifc not defined __arm__ and defined CPUARM}
55 	{$setc __arm__ := 1}
56 {$elsec}
57 	{$setc __arm__ := 0}
58 {$endc}
59 {$ifc not defined __arm64__ and defined CPUAARCH64}
60   {$setc __arm64__ := 1}
61 {$elsec}
62   {$setc __arm64__ := 0}
63 {$endc}
64 
65 {$ifc defined cpu64}
66   {$setc __LP64__ := 1}
67 {$elsec}
68   {$setc __LP64__ := 0}
69 {$endc}
70 
71 
72 {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
73 	{$error Conflicting definitions for __ppc__ and __i386__}
74 {$endc}
75 
76 {$ifc defined __ppc__ and __ppc__}
77 	{$setc TARGET_CPU_PPC := TRUE}
78 	{$setc TARGET_CPU_PPC64 := FALSE}
79 	{$setc TARGET_CPU_X86 := FALSE}
80 	{$setc TARGET_CPU_X86_64 := FALSE}
81 	{$setc TARGET_CPU_ARM := FALSE}
82 	{$setc TARGET_CPU_ARM64 := FALSE}
83 	{$setc TARGET_OS_MAC := TRUE}
84 	{$setc TARGET_OS_IPHONE := FALSE}
85 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
86 	{$setc TARGET_OS_EMBEDDED := FALSE}
87 {$elifc defined __ppc64__ and __ppc64__}
88 	{$setc TARGET_CPU_PPC := FALSE}
89 	{$setc TARGET_CPU_PPC64 := TRUE}
90 	{$setc TARGET_CPU_X86 := FALSE}
91 	{$setc TARGET_CPU_X86_64 := FALSE}
92 	{$setc TARGET_CPU_ARM := FALSE}
93 	{$setc TARGET_CPU_ARM64 := FALSE}
94 	{$setc TARGET_OS_MAC := TRUE}
95 	{$setc TARGET_OS_IPHONE := FALSE}
96 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
97 	{$setc TARGET_OS_EMBEDDED := FALSE}
98 {$elifc defined __i386__ and __i386__}
99 	{$setc TARGET_CPU_PPC := FALSE}
100 	{$setc TARGET_CPU_PPC64 := FALSE}
101 	{$setc TARGET_CPU_X86 := TRUE}
102 	{$setc TARGET_CPU_X86_64 := FALSE}
103 	{$setc TARGET_CPU_ARM := FALSE}
104 	{$setc TARGET_CPU_ARM64 := FALSE}
105 {$ifc defined iphonesim}
106  	{$setc TARGET_OS_MAC := FALSE}
107 	{$setc TARGET_OS_IPHONE := TRUE}
108 	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
109 {$elsec}
110 	{$setc TARGET_OS_MAC := TRUE}
111 	{$setc TARGET_OS_IPHONE := FALSE}
112 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
113 {$endc}
114 	{$setc TARGET_OS_EMBEDDED := FALSE}
115 {$elifc defined __x86_64__ and __x86_64__}
116 	{$setc TARGET_CPU_PPC := FALSE}
117 	{$setc TARGET_CPU_PPC64 := FALSE}
118 	{$setc TARGET_CPU_X86 := FALSE}
119 	{$setc TARGET_CPU_X86_64 := TRUE}
120 	{$setc TARGET_CPU_ARM := FALSE}
121 	{$setc TARGET_CPU_ARM64 := FALSE}
122 {$ifc defined iphonesim}
123  	{$setc TARGET_OS_MAC := FALSE}
124 	{$setc TARGET_OS_IPHONE := TRUE}
125 	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
126 {$elsec}
127 	{$setc TARGET_OS_MAC := TRUE}
128 	{$setc TARGET_OS_IPHONE := FALSE}
129 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
130 {$endc}
131 	{$setc TARGET_OS_EMBEDDED := FALSE}
132 {$elifc defined __arm__ and __arm__}
133 	{$setc TARGET_CPU_PPC := FALSE}
134 	{$setc TARGET_CPU_PPC64 := FALSE}
135 	{$setc TARGET_CPU_X86 := FALSE}
136 	{$setc TARGET_CPU_X86_64 := FALSE}
137 	{$setc TARGET_CPU_ARM := TRUE}
138 	{$setc TARGET_CPU_ARM64 := FALSE}
139 	{$setc TARGET_OS_MAC := FALSE}
140 	{$setc TARGET_OS_IPHONE := TRUE}
141 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
142 	{$setc TARGET_OS_EMBEDDED := TRUE}
143 {$elifc defined __arm64__ and __arm64__}
144 	{$setc TARGET_CPU_PPC := FALSE}
145 	{$setc TARGET_CPU_PPC64 := FALSE}
146 	{$setc TARGET_CPU_X86 := FALSE}
147 	{$setc TARGET_CPU_X86_64 := FALSE}
148 	{$setc TARGET_CPU_ARM := FALSE}
149 	{$setc TARGET_CPU_ARM64 := TRUE}
150 {$ifc defined ios}
151 	{$setc TARGET_OS_MAC := FALSE}
152 	{$setc TARGET_OS_IPHONE := TRUE}
153 	{$setc TARGET_OS_EMBEDDED := TRUE}
154 {$elsec}
155 	{$setc TARGET_OS_MAC := TRUE}
156 	{$setc TARGET_OS_IPHONE := FALSE}
157 	{$setc TARGET_OS_EMBEDDED := FALSE}
158 {$endc}
159 	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
160 {$elsec}
161 	{$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
162 {$endc}
163 
164 {$ifc defined __LP64__ and __LP64__ }
165   {$setc TARGET_CPU_64 := TRUE}
166 {$elsec}
167   {$setc TARGET_CPU_64 := FALSE}
168 {$endc}
169 
170 {$ifc defined FPC_BIG_ENDIAN}
171 	{$setc TARGET_RT_BIG_ENDIAN := TRUE}
172 	{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
173 {$elifc defined FPC_LITTLE_ENDIAN}
174 	{$setc TARGET_RT_BIG_ENDIAN := FALSE}
175 	{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
176 {$elsec}
177 	{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
178 {$endc}
179 {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
180 {$setc CALL_NOT_IN_CARBON := FALSE}
181 {$setc OLDROUTINENAMES := FALSE}
182 {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
183 {$setc OPAQUE_UPP_TYPES := TRUE}
184 {$setc OTCARBONAPPLICATION := TRUE}
185 {$setc OTKERNEL := FALSE}
186 {$setc PM_USE_SESSION_APIS := TRUE}
187 {$setc TARGET_API_MAC_CARBON := TRUE}
188 {$setc TARGET_API_MAC_OS8 := FALSE}
189 {$setc TARGET_API_MAC_OSX := TRUE}
190 {$setc TARGET_CARBON := TRUE}
191 {$setc TARGET_CPU_68K := FALSE}
192 {$setc TARGET_CPU_MIPS := FALSE}
193 {$setc TARGET_CPU_SPARC := FALSE}
194 {$setc TARGET_OS_UNIX := FALSE}
195 {$setc TARGET_OS_WIN32 := FALSE}
196 {$setc TARGET_RT_MAC_68881 := FALSE}
197 {$setc TARGET_RT_MAC_CFM := FALSE}
198 {$setc TARGET_RT_MAC_MACHO := TRUE}
199 {$setc TYPED_FUNCTION_POINTERS := TRUE}
200 {$setc TYPE_BOOL := FALSE}
201 {$setc TYPE_EXTENDED := FALSE}
202 {$setc TYPE_LONGLONG := TRUE}
203 uses MacTypes,CFBase,CFData,CFError,CFString,CFStream;
204 {$endc} {not MACOSALLINCLUDE}
205 
206 {$ALIGN POWER}
207 
208 
209 type
210 	CFPropertyListMutabilityOptions = CFOptionFlags;
211 const
212 	kCFPropertyListImmutable = 0;
213 	kCFPropertyListMutableContainers = 1;
214 	kCFPropertyListMutableContainersAndLeaves = 2;
215 
216 {
217 	Creates a property list object from its XML description; xmlData should
218 	be the raw bytes of that description, possibly the contents of an XML
219 	file. Returns NULL if the data cannot be parsed; if the parse fails
220 	and errorString is non-NULL, a human-readable description of the failure
221 	is returned in errorString. It is the caller's responsibility to release
222 	either the returned object or the error string, whichever is applicable.
223 
224         This function is obsolete and will be deprecated soon. See CFPropertyListCreateWithData() for a replacement.
225 }
CFPropertyListCreateFromXMLDatanull226 function CFPropertyListCreateFromXMLData( allocator: CFAllocatorRef; xmlData: CFDataRef; mutabilityOption: CFOptionFlags; errorString: CFStringRefPtr ): CFPropertyListRef; external name '_CFPropertyListCreateFromXMLData';
227 
228 {
229 	Returns the XML description of the given object; propertyList must
230 	be one of the supported property list types, and (for composite types
231 	like CFArray and CFDictionary) must not contain any elements that
232 	are not themselves of a property list type. If a non-property list
233 	type is encountered, NULL is returned. The returned data is
234 	appropriate for writing out to an XML file. Note that a data, not a
235 	string, is returned because the bytes contain in them a description
236 	of the string encoding used.
237 
238         This function is obsolete and will be deprecated soon. See CFPropertyListCreateData() for a replacement.
239 }
CFPropertyListCreateXMLDatanull240 function CFPropertyListCreateXMLData( allocator: CFAllocatorRef; propertyList: CFPropertyListRef ): CFDataRef; external name '_CFPropertyListCreateXMLData';
241 
242 {
243 	Recursively creates a copy of the given property list (so nested arrays
244 	and dictionaries are copied as well as the top-most container). The
245 	resulting property list has the mutability characteristics determined
246 	by mutabilityOption.
247 }
CFPropertyListCreateDeepCopynull248 function CFPropertyListCreateDeepCopy( allocator: CFAllocatorRef; propertyList: CFPropertyListRef; mutabilityOption: CFOptionFlags ): CFPropertyListRef; external name '_CFPropertyListCreateDeepCopy';
249 
250 {#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED}
251 
252 type
253 	CFPropertyListFormat = CFIndex;
254 	CFPropertyListFormatPtr = ^CFPropertyListFormat;
255 
256 const
257     kCFPropertyListOpenStepFormat = 1;
258     kCFPropertyListXMLFormat_v1_0 = 100;
259     kCFPropertyListBinaryFormat_v1_0 = 200;
260 
261 { Returns true if the object graph rooted at plist is a valid property list
262  * graph -- that is, no cycles, containing only plist objects, and dictionary
263  * keys are strings. The debugging library version spits out some messages
264  * to be helpful. The plist structure which is to be allowed is given by
265  * the format parameter. }
CFPropertyListIsValidnull266 function CFPropertyListIsValid( plist: CFPropertyListRef; format: CFPropertyListFormat ): Boolean; external name '_CFPropertyListIsValid';
267 
268 { Writes the bytes of a plist serialization out to the stream.  The
269  * stream must be opened and configured -- the function simply writes
270  * a bunch of bytes to the stream. The output plist format can be chosen.
271  * Leaves the stream open, but note that reading a plist expects the
272  * reading stream to end wherever the writing ended, so that the
273  * end of the plist data can be identified. Returns the number of bytes
274  * written, or 0 on error. Error messages are not currently localized, but
275  * may be in the future, so they are not suitable for comparison.
276  *
277  * This function is obsolete and will be deprecated soon. See CFPropertyListWrite() for a replacement. }
CFPropertyListWriteToStreamnull278 function CFPropertyListWriteToStream( propertyList: CFPropertyListRef; stream: CFWriteStreamRef; format: CFPropertyListFormat; var errorString: CFStringRef ): CFIndex; external name '_CFPropertyListWriteToStream';
279 
280 
281 { Same as current function CFPropertyListCreateFromXMLData()
282  * but takes a stream instead of data, and works on any plist file format.
283  * CFPropertyListCreateFromXMLData() also works on any plist file format.
284  * The stream must be open and configured -- the function simply reads a bunch
285  * of bytes from it starting at the current location in the stream, to the END
286  * of the stream, which is expected to be the end of the plist, or up to the
287  * number of bytes given by the length parameter if it is not 0. Error messages
288  * are not currently localized, but may be in the future, so they are not
289  * suitable for comparison.
290  *
291  * This function is obsolete and will be deprecated soon. See CFPropertyListCreateWithStream() for a replacement. }
CFPropertyListCreateFromStreamnull292 function CFPropertyListCreateFromStream( allocator: CFAllocatorRef; stream: CFReadStreamRef; streamLength: CFIndex; mutabilityOption: CFOptionFlags; var format: CFPropertyListFormat; var errorString: CFStringRef ): CFPropertyListRef; external name '_CFPropertyListCreateFromStream';
293 
294 {#endif}
295 
296 {#if MAC_OS_X_VERSION_10_6 <= MAC_OS_X_VERSION_MAX_ALLOWED}
297 const
298 	kCFPropertyListReadCorruptError = 3840; (* CF_ENUM_AVAILABLE(10_6, 4_0) *)             // Error parsing a property list
299 	kCFPropertyListReadUnknownVersionError = 3841; (* CF_ENUM_AVAILABLE(10_6, 4_0) *)      // The version number in the property list is unknown
300 	kCFPropertyListReadStreamError = 3842; (* CF_ENUM_AVAILABLE(10_6, 4_0) *)              // Stream error reading a property list
301 	kCFPropertyListWriteStreamError = 3851; (* CF_ENUM_AVAILABLE(10_6, 4_0) *)             // Stream error writing a property list
302 {#endif}
303 
304 { Create a property list with a CFData input. If the format parameter is non-NULL, it will be set to the format of the data after parsing is complete. The options parameter is used to specify CFPropertyListMutabilityOptions. If an error occurs while parsing the data, the return value will be NULL. Additionally, if an error occurs and the error parameter is non-NULL, the error parameter will be set to a CFError describing the problem, which the caller must release. If the parse succeeds, the returned value is a reference to the new property list. It is the responsibility of the caller to release this value.
305  }
CFPropertyListCreateWithDatanull306 function CFPropertyListCreateWithData( allocator: CFAllocatorRef; data: CFDataRef; options: CFOptionFlags; format: CFPropertyListFormatPtr { can be NULL };  error: CFErrorRefPtr { can be NULL } ): CFPropertyListRef; external name '_CFPropertyListCreateWithData';
307 (* CF_AVAILABLE_STARTING(10_6, 4_0) *)
308 
309 { Apple sets TARGET_OS_MAC to true for TARGET_IPHONE_SIMULATOR, but since we use unified
310   headers for Mac OS X and iPhoneSimulator, that would result in many problems -> specify
311   it explicitly }
312 {$ifc TARGET_OS_MAC or TARGET_OS_WIN32 or TARGET_OS_EMBEDDED or TARGET_IPHONE_SIMULATOR}
313 { Create and return a property list with a CFReadStream input. TIf the format parameter is non-NULL, it will be set to the format of the data after parsing is complete. The options parameter is used to specify CFPropertyListMutabilityOptions. The streamLength parameter specifies the number of bytes to read from the stream. Set streamLength to 0 to read until the end of the stream is detected. If an error occurs while parsing the data, the return value will be NULL. Additionally, if an error occurs and the error parameter is non-NULL, the error parameter will be set to a CFError describing the problem, which the caller must release. If the parse succeeds, the returned value is a reference to the new property list. It is the responsibility of the caller to release this value.
314  }
CFPropertyListCreateWithStreamnull315 function CFPropertyListCreateWithStream( allocator: CFAllocatorRef; stream: CFReadStreamRef; streamLength: CFIndex; options: CFOptionFlags;  format: CFPropertyListFormatPtr { can be NULL }; error: CFErrorRefPtr { can be NULL } ): CFPropertyListRef; external name '_CFPropertyListCreateWithStream';
316 (* CF_AVAILABLE_STARTING(10_6, 4_0) *)
317 
318 { Write the bytes of a serialized property list out to a stream. The stream must be opened and configured. The format of the property list can be chosen with the format parameter. The options parameter is currently unused and should be set to 0. The return value is the number of bytes written or 0 in the case of an error. If an error occurs and the error parameter is non-NULL, the error parameter will be set to a CFError describing the problem, which the caller must release.
319  }
CFPropertyListWritenull320 function CFPropertyListWrite( propertyList: CFPropertyListRef; stream: CFWriteStreamRef; format: CFPropertyListFormat; options: CFOptionFlags; error: CFErrorRefPtr { can be NULL } ): CFIndex; external name '_CFPropertyListWrite';
321 (* CF_AVAILABLE_STARTING(10_6, 4_0) *)
322 
323 {$endc} {TARGET_OS_MAC or TARGET_OS_WIN32 or TARGET_OS_EMBEDDED or TARGET_IPHONE_SIMULATOR}
324 
325 { Create a CFData with the bytes of a serialized property list. The format of the property list can be chosen with the format parameter. The options parameter is currently unused and should be set to 0. If an error occurs while parsing the data, the return value will be NULL. Additionally, if an error occurs and the error parameter is non-NULL, the error parameter will be set to a CFError describing the problem, which the caller must release. If the conversion succeeds, the returned value is a reference to the created data. It is the responsibility of the caller to release this value.
326  }
CFPropertyListCreateDatanull327 function CFPropertyListCreateData( allocator: CFAllocatorRef; propertyList: CFPropertyListRef; format: CFPropertyListFormat; options: CFOptionFlags; error: CFErrorRefPtr { can be NULL } ): CFDataRef; external name '_CFPropertyListCreateData';
328 (* CF_AVAILABLE_STARTING(10_6, 4_0) *)
329 
330 
331 {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
332 
333 end.
334 {$endc} {not MACOSALLINCLUDE}
335