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