]> git.saurik.com Git - apple/cf.git/blob - CFStreamInternal.h
CF-476.10.tar.gz
[apple/cf.git] / CFStreamInternal.h
1 /*
2 * Copyright (c) 2008 Apple 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 #if !defined(__COREFOUNDATION_CFSTREAMINTERNAL__)
24 #define __COREFOUNDATION_CFSTREAMINTERNAL__ 1
25
26 #include <CoreFoundation/CFStreamAbstract.h>
27 #include <CoreFoundation/CFStreamPriv.h>
28 #include <CoreFoundation/CFBase.h>
29 #include <CoreFoundation/CFRuntime.h>
30
31 CF_EXTERN_C_BEGIN
32
33
34 // Older versions of the callbacks; v0 callbacks match v1 callbacks, except that create, finalize, and copyDescription are missing.
35 typedef Boolean (*_CFStreamCBOpenV1)(struct _CFStream *stream, CFStreamError *error, Boolean *openComplete, void *info);
36 typedef Boolean (*_CFStreamCBOpenCompletedV1)(struct _CFStream *stream, CFStreamError *error, void *info);
37 typedef CFIndex (*_CFStreamCBReadV1)(CFReadStreamRef stream, UInt8 *buffer, CFIndex bufferLength, CFStreamError *error, Boolean *atEOF, void *info);
38 typedef const UInt8 *(*_CFStreamCBGetBufferV1)(CFReadStreamRef sream, CFIndex maxBytesToRead, CFIndex *numBytesRead, CFStreamError *error, Boolean *atEOF, void *info);
39 typedef Boolean (*_CFStreamCBCanReadV1)(CFReadStreamRef, void *info);
40 typedef CFIndex (*_CFStreamCBWriteV1)(CFWriteStreamRef, const UInt8 *buffer, CFIndex bufferLength, CFStreamError *error, void *info);
41 typedef Boolean (*_CFStreamCBCanWriteV1)(CFWriteStreamRef, void *info);
42
43 struct _CFStreamCallBacksV1 {
44 CFIndex version;
45 void *(*create)(struct _CFStream *stream, void *info);
46 void (*finalize)(struct _CFStream *stream, void *info);
47 CFStringRef (*copyDescription)(struct _CFStream *stream, void *info);
48
49 _CFStreamCBOpenV1 open;
50 _CFStreamCBOpenCompletedV1 openCompleted;
51 _CFStreamCBReadV1 read;
52 _CFStreamCBGetBufferV1 getBuffer;
53 _CFStreamCBCanReadV1 canRead;
54 _CFStreamCBWriteV1 write;
55 _CFStreamCBCanWriteV1 canWrite;
56 void (*close)(struct _CFStream *stream, void *info);
57
58 CFTypeRef (*copyProperty)(struct _CFStream *stream, CFStringRef propertyName, void *info);
59 Boolean (*setProperty)(struct _CFStream *stream, CFStringRef propertyName, CFTypeRef propertyValue, void *info);
60 void (*requestEvents)(struct _CFStream *stream, CFOptionFlags events, void *info);
61 void (*schedule)(struct _CFStream *stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info);
62 void (*unschedule)(struct _CFStream *stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info);
63 };
64
65 // These two are defined in CFSocketStream.c because that's where the glue for CFNetwork is.
66 __private_extern__ CFErrorRef _CFErrorFromStreamError(CFAllocatorRef alloc, CFStreamError *err);
67 __private_extern__ CFStreamError _CFStreamErrorFromError(CFErrorRef error);
68
69 CF_EXTERN_C_END
70
71 #endif /* ! __COREFOUNDATION_CFSTREAMINTERNAL__ */
72
73