]> git.saurik.com Git - apple/cf.git/blame - CFStreamPriv.h
CF-1153.18.tar.gz
[apple/cf.git] / CFStreamPriv.h
CommitLineData
d8925383 1/*
e29e285d 2 * Copyright (c) 2015 Apple Inc. All rights reserved.
d8925383
A
3 *
4 * @APPLE_LICENSE_HEADER_START@
d7384798 5 *
d8925383
A
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.
d7384798 12 *
d8925383
A
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.
d7384798 20 *
d8925383
A
21 * @APPLE_LICENSE_HEADER_END@
22 */
f64f9b69 23
d8925383 24/* CFStreamPriv.h
d7384798 25 Copyright (c) 2000-2014, Apple Inc. All rights reserved.
d8925383
A
26*/
27
28#if !defined(__COREFOUNDATION_CFSTREAMPRIV__)
29#define __COREFOUNDATION_CFSTREAMPRIV__ 1
30
d8925383 31#include <CoreFoundation/CFStream.h>
d8925383 32#include <CoreFoundation/CFRunLoop.h>
bd5b749c 33#include <CoreFoundation/CFRuntime.h>
d8925383 34
bd5b749c 35CF_EXTERN_C_BEGIN
d8925383
A
36
37struct _CFStream;
38struct _CFStreamClient {
39 CFStreamClientContext cbContext;
40 void (*cb)(struct _CFStream *, CFStreamEventType, void *);
41 CFOptionFlags when;
42 CFRunLoopSourceRef rlSource;
43 CFMutableArrayRef runLoopsAndModes;
44 CFOptionFlags whatToSignal;
45};
46
bd5b749c
A
47#define CFStreamCurrentVersion 2
48
d8925383
A
49// A unified set of callbacks so we can use a single structure for all struct _CFStreams.
50struct _CFStreamCallBacks {
51 CFIndex version;
52 void *(*create)(struct _CFStream *stream, void *info);
53 void (*finalize)(struct _CFStream *stream, void *info);
54 CFStringRef (*copyDescription)(struct _CFStream *stream, void *info);
bd5b749c
A
55
56 Boolean (*open)(struct _CFStream *stream, CFErrorRef *error, Boolean *openComplete, void *info);
57 Boolean (*openCompleted)(struct _CFStream *stream, CFErrorRef *error, void *info);
58 CFIndex (*read)(CFReadStreamRef stream, UInt8 *buffer, CFIndex bufferLength, CFErrorRef *error, Boolean *atEOF, void *info);
59 const UInt8 *(*getBuffer)(CFReadStreamRef sream, CFIndex maxBytesToRead, CFIndex *numBytesRead, CFErrorRef *error, Boolean *atEOF, void *info);
60 Boolean (*canRead)(CFReadStreamRef, CFErrorRef *error, void *info);
61 CFIndex (*write)(CFWriteStreamRef, const UInt8 *buffer, CFIndex bufferLength, CFErrorRef *error, void *info);
62 Boolean (*canWrite)(CFWriteStreamRef, CFErrorRef *error, void *info);
d8925383 63 void (*close)(struct _CFStream *stream, void *info);
bd5b749c 64
d8925383
A
65 CFTypeRef (*copyProperty)(struct _CFStream *stream, CFStringRef propertyName, void *info);
66 Boolean (*setProperty)(struct _CFStream *stream, CFStringRef propertyName, CFTypeRef propertyValue, void *info);
67 void (*requestEvents)(struct _CFStream *stream, CFOptionFlags events, void *info);
68 void (*schedule)(struct _CFStream *stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info);
69 void (*unschedule)(struct _CFStream *stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void *info);
70};
71
a48904a4 72struct _CFStream;
d8925383 73
a48904a4 74CF_EXPORT void* _CFStreamGetInfoPointer(struct _CFStream* stream);
bd5b749c
A
75
76// cb version must be > 0
d8925383
A
77CF_EXPORT struct _CFStream *_CFStreamCreateWithConstantCallbacks(CFAllocatorRef alloc, void *info, const struct _CFStreamCallBacks *cb, Boolean isReading);
78
79// Only available for streams created with _CFStreamCreateWithConstantCallbacks, above. cb's version must be 1
80CF_EXPORT void _CFStreamSetInfoPointer(struct _CFStream *stream, void *info, const struct _CFStreamCallBacks *cb);
81
d8925383
A
82/*
83** _CFStreamSourceScheduleWithRunLoop
84**
85** Schedules the given run loop source on the given run loop and mode. It then
86** adds the loop and mode pair to the runLoopsAndModes list. The list is
87** simply a linear list of a loop reference followed by a mode reference.
88**
89** source Run loop source to be scheduled
90**
91** runLoopsAndModes List of run loop/mode pairs on which the source is scheduled
92**
93** runLoop Run loop on which the source is being scheduled
94**
95** runLoopMode Run loop mode on which the source is being scheduled
96*/
97CF_EXPORT
98void _CFStreamSourceScheduleWithRunLoop(CFRunLoopSourceRef source, CFMutableArrayRef runLoopsAndModes, CFRunLoopRef runLoop, CFStringRef runLoopMode);
99
100
101/*
102** _CFStreamSourceUnscheduleFromRunLoop
103**
104** Unschedule the given source from the given run loop and mode. It then will
105** guarantee that the source remains scheduled on the list of run loop and mode
106** pairs in the runLoopsAndModes list. The list is simply a linear list of a
107** loop reference followed by a mode reference.
108**
109** source Run loop source to be unscheduled
110**
111** runLoopsAndModes List of run loop/mode pairs on which the source is scheduled
112**
113** runLoop Run loop from which the source is being unscheduled
114**
115** runLoopMode Run loop mode from which the source is being unscheduled
116*/
117CF_EXPORT
118void _CFStreamSourceUnscheduleFromRunLoop(CFRunLoopSourceRef source, CFMutableArrayRef runLoopsAndModes, CFRunLoopRef runLoop, CFStringRef runLoopMode);
119
120
121/*
122** _CFStreamSourceScheduleWithAllRunLoops
123**
124** Schedules the given run loop source on all the run loops and modes in the list.
125** The list is simply a linear list of a loop reference followed by a mode reference.
126**
127** source Run loop source to be unscheduled
128**
129** runLoopsAndModes List of run loop/mode pairs on which the source is scheduled
130*/
131CF_EXPORT
132void _CFStreamSourceScheduleWithAllRunLoops(CFRunLoopSourceRef source, CFArrayRef runLoopsAndModes);
133
134
135/*
136** _CFStreamSourceUnscheduleFromRunLoop
137**
138** Unschedule the given source from all the run loops and modes in the list.
139** The list is simply a linear list of a loop reference followed by a mode
140** reference.
141**
142** source Run loop source to be unscheduled
143**
144** runLoopsAndModes List of run loop/mode pairs on which the source is scheduled
145*/
146CF_EXPORT
147void _CFStreamSourceUncheduleFromAllRunLoops(CFRunLoopSourceRef source, CFArrayRef runLoopsAndModes);
148
bd5b749c
A
149CF_EXPORT
150CFReadStreamRef _CFReadStreamCreateFromFileDescriptor(CFAllocatorRef alloc, int fd);
151
152CF_EXPORT
153CFWriteStreamRef _CFWriteStreamCreateFromFileDescriptor(CFAllocatorRef alloc, int fd);
154
155
d8925383
A
156
157#define SECURITY_NONE (0)
158#define SECURITY_SSLv2 (1)
159#define SECURITY_SSLv3 (2)
160#define SECURITY_SSLv32 (3)
161#define SECURITY_TLS (4)
162
cf7d2af9 163#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)) || (TARGET_OS_EMBEDDED || TARGET_OS_IPHONE)
bd5b749c
A
164// This symbol is exported from CFNetwork (see CFSocketStream.i). Only __MACH__ systems will
165// get this symbol from CoreFoundation.
d8925383 166extern const int kCFStreamErrorDomainSSL;
cf7d2af9 167#endif
d8925383 168
bd5b749c
A
169/*
170 * Additional SPI for CFNetwork for select side read buffering
171 */
172CF_EXPORT
173Boolean __CFSocketGetBytesAvailable(CFSocketRef s, CFIndex* ctBytesAvailable);
174
175CF_EXPORT
176CFIndex __CFSocketRead(CFSocketRef s, UInt8* buffer, CFIndex length, int* error);
177
cf7d2af9
A
178/*
179 * This define can be removed once 6030579 is removed
180 */
181#define CFNETWORK_6030579 1
bd5b749c
A
182
183CF_EXPORT
cf7d2af9 184void __CFSocketSetSocketReadBufferAttrs(CFSocketRef s, CFTimeInterval timeout, CFIndex length);
bd5b749c
A
185
186CF_EXTERN_C_END
d8925383 187
856091c5
A
188/*
189 * for CF{Read/Write}StreamCopyProperty created from a file. The
190 * result is a CFDataRef containing sizeof(int) bytes in machine byte
191 * ordering representing the file descriptor of the underlying open
192 * file. If the underlying file descriptor is not open, the property
193 * value will be NULL (as opposed to containing ((int) -1)).
194 */
195CF_EXPORT const CFStringRef _kCFStreamPropertyFileNativeHandle CF_AVAILABLE_IOS(5_0);
196
d8925383
A
197#endif /* ! __COREFOUNDATION_CFSTREAMPRIV__ */
198