PageRenderTime 38ms CodeModel.GetById 16ms app.highlight 7ms RepoModel.GetById 6ms app.codeStats 0ms

/packages/univint/src/CFStream.pas

https://github.com/slibre/freepascal
Pascal | 404 lines | 96 code | 53 blank | 255 comment | 0 complexity | 24010b9bee0a6a355e5b6bea17259e63 MD5 | raw file
Possible License(s): LGPL-2.0, LGPL-2.1, LGPL-3.0
  1{	CFStream.h
  2	Copyright (c) 2000-2012, Apple Inc. All rights reserved.
  3}
  4{	  Pascal Translation:  Peter N Lewis, <peter@stairways.com.au>, 2004 }
  5{	  Pascal Translation Updated:  Peter N Lewis, <peter@stairways.com.au>, November 2005 }
  6{     Pascal Translation Updated:  Gale R Paeper, <gpaeper@empirenet.com>, 2008 }
  7{   Pascal Translation Updated:  Gorazd Krosl, <gorazd_1957@yahoo.ca>, October 2009 }
  8{   Pascal Translation Updated:  Jonas Maebe, <jonas@freepascal.org>, October 2009 }
  9{   Pascal Translation Updated:  Jonas Maebe <jonas@freepascal.org>, September 2012 }
 10{
 11    Modified for use with Free Pascal
 12    Version 308
 13    Please report any bugs to <gpc@microbizz.nl>
 14}
 15
 16{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
 17{$mode macpas}
 18{$packenum 1}
 19{$macro on}
 20{$inline on}
 21{$calling mwpascal}
 22
 23unit CFStream;
 24interface
 25{$setc UNIVERSAL_INTERFACES_VERSION := $0400}
 26{$setc GAP_INTERFACES_VERSION := $0308}
 27
 28{$ifc not defined USE_CFSTR_CONSTANT_MACROS}
 29    {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
 30{$endc}
 31
 32{$ifc defined CPUPOWERPC and defined CPUI386}
 33	{$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
 34{$endc}
 35{$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
 36	{$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
 37{$endc}
 38
 39{$ifc not defined __ppc__ and defined CPUPOWERPC32}
 40	{$setc __ppc__ := 1}
 41{$elsec}
 42	{$setc __ppc__ := 0}
 43{$endc}
 44{$ifc not defined __ppc64__ and defined CPUPOWERPC64}
 45	{$setc __ppc64__ := 1}
 46{$elsec}
 47	{$setc __ppc64__ := 0}
 48{$endc}
 49{$ifc not defined __i386__ and defined CPUI386}
 50	{$setc __i386__ := 1}
 51{$elsec}
 52	{$setc __i386__ := 0}
 53{$endc}
 54{$ifc not defined __x86_64__ and defined CPUX86_64}
 55	{$setc __x86_64__ := 1}
 56{$elsec}
 57	{$setc __x86_64__ := 0}
 58{$endc}
 59{$ifc not defined __arm__ and defined CPUARM}
 60	{$setc __arm__ := 1}
 61{$elsec}
 62	{$setc __arm__ := 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_OS_MAC := TRUE}
 83	{$setc TARGET_OS_IPHONE := FALSE}
 84	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
 85	{$setc TARGET_OS_EMBEDDED := FALSE}
 86{$elifc defined __ppc64__ and __ppc64__}
 87	{$setc TARGET_CPU_PPC := FALSE}
 88	{$setc TARGET_CPU_PPC64 := TRUE}
 89	{$setc TARGET_CPU_X86 := FALSE}
 90	{$setc TARGET_CPU_X86_64 := FALSE}
 91	{$setc TARGET_CPU_ARM := FALSE}
 92	{$setc TARGET_OS_MAC := TRUE}
 93	{$setc TARGET_OS_IPHONE := FALSE}
 94	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
 95	{$setc TARGET_OS_EMBEDDED := FALSE}
 96{$elifc defined __i386__ and __i386__}
 97	{$setc TARGET_CPU_PPC := FALSE}
 98	{$setc TARGET_CPU_PPC64 := FALSE}
 99	{$setc TARGET_CPU_X86 := TRUE}
100	{$setc TARGET_CPU_X86_64 := FALSE}
101	{$setc TARGET_CPU_ARM := FALSE}
102{$ifc defined(iphonesim)}
103 	{$setc TARGET_OS_MAC := FALSE}
104	{$setc TARGET_OS_IPHONE := TRUE}
105	{$setc TARGET_IPHONE_SIMULATOR := TRUE}
106{$elsec}
107	{$setc TARGET_OS_MAC := TRUE}
108	{$setc TARGET_OS_IPHONE := FALSE}
109	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
110{$endc}
111	{$setc TARGET_OS_EMBEDDED := FALSE}
112{$elifc defined __x86_64__ and __x86_64__}
113	{$setc TARGET_CPU_PPC := FALSE}
114	{$setc TARGET_CPU_PPC64 := FALSE}
115	{$setc TARGET_CPU_X86 := FALSE}
116	{$setc TARGET_CPU_X86_64 := TRUE}
117	{$setc TARGET_CPU_ARM := FALSE}
118	{$setc TARGET_OS_MAC := TRUE}
119	{$setc TARGET_OS_IPHONE := FALSE}
120	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
121	{$setc TARGET_OS_EMBEDDED := FALSE}
122{$elifc defined __arm__ and __arm__}
123	{$setc TARGET_CPU_PPC := FALSE}
124	{$setc TARGET_CPU_PPC64 := FALSE}
125	{$setc TARGET_CPU_X86 := FALSE}
126	{$setc TARGET_CPU_X86_64 := FALSE}
127	{$setc TARGET_CPU_ARM := TRUE}
128	{ will require compiler define when/if other Apple devices with ARM cpus ship }
129	{$setc TARGET_OS_MAC := FALSE}
130	{$setc TARGET_OS_IPHONE := TRUE}
131	{$setc TARGET_IPHONE_SIMULATOR := FALSE}
132	{$setc TARGET_OS_EMBEDDED := TRUE}
133{$elsec}
134	{$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ is defined.}
135{$endc}
136
137{$ifc defined __LP64__ and __LP64__ }
138  {$setc TARGET_CPU_64 := TRUE}
139{$elsec}
140  {$setc TARGET_CPU_64 := FALSE}
141{$endc}
142
143{$ifc defined FPC_BIG_ENDIAN}
144	{$setc TARGET_RT_BIG_ENDIAN := TRUE}
145	{$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
146{$elifc defined FPC_LITTLE_ENDIAN}
147	{$setc TARGET_RT_BIG_ENDIAN := FALSE}
148	{$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
149{$elsec}
150	{$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
151{$endc}
152{$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
153{$setc CALL_NOT_IN_CARBON := FALSE}
154{$setc OLDROUTINENAMES := FALSE}
155{$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
156{$setc OPAQUE_UPP_TYPES := TRUE}
157{$setc OTCARBONAPPLICATION := TRUE}
158{$setc OTKERNEL := FALSE}
159{$setc PM_USE_SESSION_APIS := TRUE}
160{$setc TARGET_API_MAC_CARBON := TRUE}
161{$setc TARGET_API_MAC_OS8 := FALSE}
162{$setc TARGET_API_MAC_OSX := TRUE}
163{$setc TARGET_CARBON := TRUE}
164{$setc TARGET_CPU_68K := FALSE}
165{$setc TARGET_CPU_MIPS := FALSE}
166{$setc TARGET_CPU_SPARC := FALSE}
167{$setc TARGET_OS_UNIX := FALSE}
168{$setc TARGET_OS_WIN32 := FALSE}
169{$setc TARGET_RT_MAC_68881 := FALSE}
170{$setc TARGET_RT_MAC_CFM := FALSE}
171{$setc TARGET_RT_MAC_MACHO := TRUE}
172{$setc TYPED_FUNCTION_POINTERS := TRUE}
173{$setc TYPE_BOOL := FALSE}
174{$setc TYPE_EXTENDED := FALSE}
175{$setc TYPE_LONGLONG := TRUE}
176uses MacTypes,CFBase,CFString,CFDictionary,CFURL,CFRunLoop,CFSocket,CFError;
177{$endc} {not MACOSALLINCLUDE}
178
179{$ALIGN POWER}
180
181
182const
183	kCFStreamStatusNotOpen = 0;
184	kCFStreamStatusOpening = 1;  { open is in-progress }
185	kCFStreamStatusOpen = 2;
186	kCFStreamStatusReading = 3;
187	kCFStreamStatusWriting = 4;
188	kCFStreamStatusAtEnd = 5;    { no further bytes can be read/written }
189	kCFStreamStatusClosed = 6;
190	kCFStreamStatusError = 7;
191type
192	CFStreamStatus = CFIndex;
193
194const
195	kCFStreamEventNone = 0;
196	kCFStreamEventOpenCompleted = 1;
197	kCFStreamEventHasBytesAvailable = 2;
198	kCFStreamEventCanAcceptBytes = 4;
199	kCFStreamEventErrorOccurred = 8;
200	kCFStreamEventEndEncountered = 16;
201type
202	CFStreamEventType = CFOptionFlags;
203
204type
205	CFStreamClientContext = record
206		version: CFIndex;
207		info: UnivPtr;
208		retain: function( info: {const} UnivPtr ): UnivPtr;
209		release: procedure( info: {const} UnivPtr );
210		copyDescription: function( info: {const} UnivPtr ): CFStringRef;
211	end;
212
213type
214	CFReadStreamRef = ^__CFReadStream; { an opaque type }
215	__CFReadStream = record end;
216	CFWriteStreamRefPtr = ^CFWriteStreamRef;
217	CFWriteStreamRef = ^__CFWriteStream; { an opaque type }
218	__CFWriteStream = record end;
219	CFReadStreamRefPtr = ^CFReadStreamRef;
220
221type
222	CFReadStreamClientCallBack = procedure( stream: CFReadStreamRef; typ: CFStreamEventType; clientCallBackInfo: UnivPtr );
223	CFWriteStreamClientCallBack = procedure( stream: CFWriteStreamRef; typ: CFStreamEventType; clientCallBackInfo: UnivPtr );
224
225function CFReadStreamGetTypeID: CFTypeID; external name '_CFReadStreamGetTypeID';
226function CFWriteStreamGetTypeID: CFTypeID; external name '_CFWriteStreamGetTypeID';
227
228{ Memory streams }
229
230{ Value will be a CFData containing all bytes thusfar written; used to recover the data written to a memory write stream. }
231var kCFStreamPropertyDataWritten: CFStringRef; external name '_kCFStreamPropertyDataWritten'; (* attribute const *)
232
233{ Pass kCFAllocatorNull for bytesDeallocator to prevent CFReadStream from deallocating bytes; otherwise, CFReadStream will deallocate bytes when the stream is destroyed }
234function CFReadStreamCreateWithBytesNoCopy( alloc: CFAllocatorRef; bytes: UnivPtr; length: CFIndex; bytesDeallocator: CFAllocatorRef ): CFReadStreamRef; external name '_CFReadStreamCreateWithBytesNoCopy';
235
236{ The stream writes into the buffer given; when bufferCapacity is exhausted, the stream is exhausted (status becomes kCFStreamStatusAtEnd) }
237function CFWriteStreamCreateWithBuffer( alloc: CFAllocatorRef; buffer: UnivPtr; bufferCapacity: CFIndex ): CFWriteStreamRef; external name '_CFWriteStreamCreateWithBuffer';
238
239{ New buffers are allocated from bufferAllocator as bytes are written to the stream.  At any point, you can recover the bytes thusfar written by asking for the property kCFStreamPropertyDataWritten, above }
240function CFWriteStreamCreateWithAllocatedBuffers( alloc: CFAllocatorRef; bufferAllocator: CFAllocatorRef ): CFWriteStreamRef; external name '_CFWriteStreamCreateWithAllocatedBuffers';
241
242{ File streams }
243function CFReadStreamCreateWithFile( alloc: CFAllocatorRef; fileURL: CFURLRef ): CFReadStreamRef; external name '_CFReadStreamCreateWithFile';
244function CFWriteStreamCreateWithFile( alloc: CFAllocatorRef; fileURL: CFURLRef ): CFWriteStreamRef; external name '_CFWriteStreamCreateWithFile';
245{ CF_IMPLICIT_BRIDGING_DISABLED }
246procedure CFStreamCreateBoundPair( alloc: CFAllocatorRef; var readStream: CFReadStreamRef; var writeStream: CFWriteStreamRef; transferBufferSize: CFIndex ); external name '_CFStreamCreateBoundPair';
247{ CF_IMPLICIT_BRIDGING_ENABLED }
248
249{#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED}
250{ Property for file write streams; value should be a CFBoolean.  Set to TRUE to append to a file, rather than to replace its contents }
251var kCFStreamPropertyAppendToFile: CFStringRef; external name '_kCFStreamPropertyAppendToFile'; (* attribute const *)
252{#endif}
253
254// Value is a CFNumber
255var kCFStreamPropertyFileCurrentOffset: CFStringRef; external name '_kCFStreamPropertyFileCurrentOffset'; (* attribute const *)
256(* AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER *)
257
258{ Socket stream properties }
259
260{ Value will be a CFData containing the native handle }
261var kCFStreamPropertySocketNativeHandle: CFStringRef; external name '_kCFStreamPropertySocketNativeHandle'; (* attribute const *)
262
263{ Value will be a CFString, or NULL if unknown }
264var kCFStreamPropertySocketRemoteHostName: CFStringRef; external name '_kCFStreamPropertySocketRemoteHostName'; (* attribute const *)
265
266{ Value will be a CFNumber, or NULL if unknown }
267var kCFStreamPropertySocketRemotePortNumber: CFStringRef; external name '_kCFStreamPropertySocketRemotePortNumber'; (* attribute const *)
268
269{ Socket streams; the returned streams are paired such that they use the same socket; pass NULL if you want only the read stream or the write stream }
270procedure CFStreamCreatePairWithSocket( alloc: CFAllocatorRef; sock: CFSocketNativeHandle; var readStream: CFReadStreamRef; var writeStream: CFWriteStreamRef ); external name '_CFStreamCreatePairWithSocket';
271procedure CFStreamCreatePairWithSocketToHost( alloc: CFAllocatorRef; host: CFStringRef; port: UInt32; var readStream: CFReadStreamRef; var writeStream: CFWriteStreamRef ); external name '_CFStreamCreatePairWithSocketToHost';
272{#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED}
273procedure CFStreamCreatePairWithPeerSocketSignature( alloc: CFAllocatorRef; const (*var*) signature: CFSocketSignature; var readStream: CFReadStreamRef; var writeStream: CFWriteStreamRef ); external name '_CFStreamCreatePairWithPeerSocketSignature';
274{#endif}
275
276
277{ Returns the current state of the stream }
278function CFReadStreamGetStatus( stream: CFReadStreamRef ): CFStreamStatus; external name '_CFReadStreamGetStatus';
279function CFWriteStreamGetStatus( stream: CFWriteStreamRef ): CFStreamStatus; external name '_CFWriteStreamGetStatus';
280
281{ Returns NULL if no error has occurred; otherwise returns the error. }
282function CFReadStreamCopyError( stream: CFReadStreamRef ): CFErrorRef; external name '_CFReadStreamCopyError';
283(* CF_AVAILABLE_STARTING(10_5, 2_0) *)
284function CFWriteStreamCopyError( stream: CFWriteStreamRef ): CFErrorRef; external name '_CFWriteStreamCopyError';
285(* CF_AVAILABLE_STARTING(10_5, 2_0) *)
286
287{ Returns success/failure.  Opening a stream causes it to reserve all the system
288   resources it requires.  If the stream can open non-blocking, this will always 
289   return TRUE; listen to the run loop source to find out when the open completes
290   and whether it was successful, or poll using CFRead/WriteStreamGetStatus(), waiting 
291   for a status of kCFStreamStatusOpen or kCFStreamStatusError.  }
292function CFReadStreamOpen( stream: CFReadStreamRef ): Boolean; external name '_CFReadStreamOpen';
293function CFWriteStreamOpen( stream: CFWriteStreamRef ): Boolean; external name '_CFWriteStreamOpen';
294
295{ Terminates the flow of bytes; releases any system resources required by the 
296   stream.  The stream may not fail to close.  You may call CFStreamClose() to 
297   effectively abort a stream. }
298procedure CFReadStreamClose( stream: CFReadStreamRef ); external name '_CFReadStreamClose';
299procedure CFWriteStreamClose( stream: CFWriteStreamRef ); external name '_CFWriteStreamClose';
300
301{ Whether there is data currently available for reading; returns TRUE if it's 
302   impossible to tell without trying }
303function CFReadStreamHasBytesAvailable( stream: CFReadStreamRef ): Boolean; external name '_CFReadStreamHasBytesAvailable';
304
305{ Returns the number of bytes read, or -1 if an error occurs preventing any 
306   bytes from being read, or 0 if the stream's end was encountered.  
307   It is an error to try and read from a stream that hasn't been opened first.  
308   This call will block until at least one byte is available; it will NOT block
309   until the entire buffer can be filled.  To avoid blocking, either poll using
310   CFReadStreamHasBytesAvailable() or use the run loop and listen for the 
311   kCFStreamCanRead event for notification of data available. }
312function CFReadStreamRead( stream: CFReadStreamRef; buffer: UnivPtr; bufferLength: CFIndex ): CFIndex; external name '_CFReadStreamRead';
313
314{ Returns a pointer to an internal buffer if possible (setting *numBytesRead
315   to the length of the returned buffer), otherwise returns NULL; guaranteed 
316   to return in O(1).  Bytes returned in the buffer are considered read from 
317   the stream; if maxBytesToRead is greater than 0, not more than maxBytesToRead
318   will be returned.  If maxBytesToRead is less than or equal to zero, as many bytes
319   as are readily available will be returned.  The returned buffer is good only 
320   until the next stream operation called on the stream.  Caller should neither 
321   change the contents of the returned buffer nor attempt to deallocate the buffer;
322   it is still owned by the stream. }
323function CFReadStreamGetBuffer( stream: CFReadStreamRef; maxBytesToRead: CFIndex; var numBytesRead: CFIndex ): UInt8Ptr; external name '_CFReadStreamGetBuffer';
324
325{ Whether the stream can currently be written to without blocking;
326   returns TRUE if it's impossible to tell without trying }
327function CFWriteStreamCanAcceptBytes( stream: CFWriteStreamRef ): Boolean; external name '_CFWriteStreamCanAcceptBytes';
328
329{ Returns the number of bytes successfully written, -1 if an error has
330   occurred, or 0 if the stream has been filled to capacity (for fixed-length
331   streams).  If the stream is not full, this call will block until at least
332   one byte is written.  To avoid blocking, either poll via CFWriteStreamCanAcceptBytes
333   or use the run loop and listen for the kCFStreamCanWrite event. }
334function CFWriteStreamWrite( stream: CFWriteStreamRef; buffer: UnivPtr; bufferLength: CFIndex ): CFIndex; external name '_CFWriteStreamWrite';
335
336{ Particular streams can name properties and assign meanings to them; you
337   access these properties through the following calls.  A property is any interesting
338   information about the stream other than the data being transmitted itself.
339   Examples include the headers from an HTTP transmission, or the expected 
340   number of bytes, or permission information, etc.  Properties that can be set
341   configure the behavior of the stream, and may only be settable at particular times
342   (like before the stream has been opened).  See the documentation for particular 
343   properties to determine their get- and set-ability. }
344function CFReadStreamCopyProperty( stream: CFReadStreamRef; propertyName: CFStringRef ): CFTypeRef; external name '_CFReadStreamCopyProperty';
345function CFWriteStreamCopyProperty( stream: CFWriteStreamRef; propertyName: CFStringRef ): CFTypeRef; external name '_CFWriteStreamCopyProperty';
346
347{#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED}
348{ Returns TRUE if the stream recognizes and accepts the given property-value pair; 
349   FALSE otherwise. }
350function CFReadStreamSetProperty( stream: CFReadStreamRef; propertyName: CFStringRef; propertyValue: CFTypeRef ): Boolean; external name '_CFReadStreamSetProperty';
351function CFWriteStreamSetProperty( stream: CFWriteStreamRef; propertyName: CFStringRef; propertyValue: CFTypeRef ): Boolean; external name '_CFWriteStreamSetProperty';
352{#endif}
353
354{ Asynchronous processing - If you wish to neither poll nor block, you may register 
355   a client to hear about interesting events that occur on a stream.  Only one client
356   per stream is allowed; registering a new client replaces the previous one.
357
358   Once you have set a client, you need to schedule a run loop on which that client
359   can be notified.  You may schedule multiple run loops (for instance, if you are 
360   using a thread pool).  The client callback will be triggered via one of the scheduled
361   run loops; It is the caller's responsibility to ensure that at least one of the 
362   scheduled run loops is being run.
363
364   NOTE: Unlike other CoreFoundation APIs, pasing a NULL clientContext here will remove
365   the client.  If you do not care about the client context (i.e. your only concern
366   is that your callback be called), you should pass in a valid context where every
367   entry is 0 or NULL.
368
369}
370
371function CFReadStreamSetClient( stream: CFReadStreamRef; streamEvents: CFOptionFlags; clientCB: CFReadStreamClientCallBack; var clientContext: CFStreamClientContext ): Boolean; external name '_CFReadStreamSetClient';
372function CFWriteStreamSetClient( stream: CFWriteStreamRef; streamEvents: CFOptionFlags; clientCB: CFWriteStreamClientCallBack; var clientContext: CFStreamClientContext ): Boolean; external name '_CFWriteStreamSetClient';
373
374procedure CFReadStreamScheduleWithRunLoop( stream: CFReadStreamRef; runLoop: CFRunLoopRef; runLoopMode: CFStringRef ); external name '_CFReadStreamScheduleWithRunLoop';
375procedure CFWriteStreamScheduleWithRunLoop( stream: CFWriteStreamRef; runLoop: CFRunLoopRef; runLoopMode: CFStringRef ); external name '_CFWriteStreamScheduleWithRunLoop';
376
377procedure CFReadStreamUnscheduleFromRunLoop( stream: CFReadStreamRef; runLoop: CFRunLoopRef; runLoopMode: CFStringRef ); external name '_CFReadStreamUnscheduleFromRunLoop';
378procedure CFWriteStreamUnscheduleFromRunLoop( stream: CFWriteStreamRef; runLoop: CFRunLoopRef; runLoopMode: CFStringRef ); external name '_CFWriteStreamUnscheduleFromRunLoop';
379
380
381{ The following API is deprecated starting in 10.5; please use CFRead/WriteStreamCopyError(), above, instead }
382const
383	kCFStreamErrorDomainCustom = -1;      { custom to the kind of stream in question }
384	kCFStreamErrorDomainPOSIX = 1;        { POSIX errno; interpret using <sys/errno.h> }
385	kCFStreamErrorDomainMacOSStatus = 2;      { OSStatus type from Carbon APIs; interpret using <MacTypes.h> }
386type
387	CFStreamErrorDomain = CFIndex;
388
389type
390	CFStreamError = record
391		domain: CFIndex; 
392		error: SInt32;
393	end;
394	CFStreamErrorPtr = ^CFStreamError;
395
396{ 0 is returned if no error has occurred.  errorDomain specifies the domain
397   in which the error code should be interpretted; pass NULL if you are not 
398   interested. }
399function CFReadStreamGetError( stream: CFReadStreamRef ): CFStreamError; external name '_CFReadStreamGetError';
400function CFWriteStreamGetError( stream: CFWriteStreamRef ): CFStreamError; external name '_CFWriteStreamGetError';
401{$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
402
403end.
404{$endc} {not MACOSALLINCLUDE}