X-Git-Url: https://git.saurik.com/apple/cf.git/blobdiff_plain/cf7d2af96685aba74e84652f9ed1098e9253902e..d73847987a99375010c6d6ace0abb0a25cb9b034:/CFSocket.h diff --git a/CFSocket.h b/CFSocket.h index 7e6f71c..b591711 100644 --- a/CFSocket.h +++ b/CFSocket.h @@ -1,15 +1,15 @@ /* - * Copyright (c) 2009 Apple Inc. All rights reserved. + * Copyright (c) 2014 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ - * + * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. - * + * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, @@ -17,27 +17,21 @@ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. - * + * * @APPLE_LICENSE_HEADER_END@ */ + /* CFSocket.h - Copyright (c) 1999-2009, Apple Inc. All rights reserved. + Copyright (c) 1999-2014, Apple Inc. All rights reserved. */ #if !defined(__COREFOUNDATION_CFSOCKET__) #define __COREFOUNDATION_CFSOCKET__ 1 -#include - -#if TARGET_OS_WIN32 -typedef uintptr_t CFSocketNativeHandle; -#else -typedef int CFSocketNativeHandle; -#endif - #include #include +CF_IMPLICIT_BRIDGING_ENABLED CF_EXTERN_C_BEGIN typedef struct __CFSocket * CFSocketRef; @@ -120,12 +114,11 @@ filled in properly when passing in an address. */ /* Values for CFSocketError */ -enum { +typedef CF_ENUM(CFIndex, CFSocketError) { kCFSocketSuccess = 0, - kCFSocketError = -1, - kCFSocketTimeout = -2 + kCFSocketError = -1L, + kCFSocketTimeout = -2L }; -typedef CFIndex CFSocketError; typedef struct { SInt32 protocolFamily; @@ -135,32 +128,24 @@ typedef struct { } CFSocketSignature; /* Values for CFSocketCallBackType */ -enum { +typedef CF_OPTIONS(CFOptionFlags, CFSocketCallBackType) { kCFSocketNoCallBack = 0, kCFSocketReadCallBack = 1, kCFSocketAcceptCallBack = 2, kCFSocketDataCallBack = 3, - kCFSocketConnectCallBack = 4 -#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED - , + kCFSocketConnectCallBack = 4, kCFSocketWriteCallBack = 8 -#endif }; -typedef CFOptionFlags CFSocketCallBackType; -#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED /* Socket flags */ enum { kCFSocketAutomaticallyReenableReadCallBack = 1, kCFSocketAutomaticallyReenableAcceptCallBack = 2, kCFSocketAutomaticallyReenableDataCallBack = 3, kCFSocketAutomaticallyReenableWriteCallBack = 8, -#if MAC_OS_X_VERSION_10_5 <= MAC_OS_X_VERSION_MAX_ALLOWED - kCFSocketLeaveErrors = 64, -#endif + kCFSocketLeaveErrors CF_ENUM_AVAILABLE(10_5, 2_0) = 64, kCFSocketCloseOnInvalidate = 128 }; -#endif typedef void (*CFSocketCallBack)(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void *data, void *info); /* If the callback wishes to keep hold of address or data after the point that it returns, then it must copy them. */ @@ -173,13 +158,20 @@ typedef struct { CFStringRef (*copyDescription)(const void *info); } CFSocketContext; +#if TARGET_OS_WIN32 +typedef uintptr_t CFSocketNativeHandle; +#else +typedef int CFSocketNativeHandle; +#endif + CF_EXPORT CFTypeID CFSocketGetTypeID(void); CF_EXPORT CFSocketRef CFSocketCreate(CFAllocatorRef allocator, SInt32 protocolFamily, SInt32 socketType, SInt32 protocol, CFOptionFlags callBackTypes, CFSocketCallBack callout, const CFSocketContext *context); CF_EXPORT CFSocketRef CFSocketCreateWithNative(CFAllocatorRef allocator, CFSocketNativeHandle sock, CFOptionFlags callBackTypes, CFSocketCallBack callout, const CFSocketContext *context); CF_EXPORT CFSocketRef CFSocketCreateWithSocketSignature(CFAllocatorRef allocator, const CFSocketSignature *signature, CFOptionFlags callBackTypes, CFSocketCallBack callout, const CFSocketContext *context); +/* CFSocketCreateWithSocketSignature() creates a socket of the requested type and binds its address (using CFSocketSetAddress()) to the requested address. If this fails, it returns NULL. */ CF_EXPORT CFSocketRef CFSocketCreateConnectedToSocketSignature(CFAllocatorRef allocator, const CFSocketSignature *signature, CFOptionFlags callBackTypes, CFSocketCallBack callout, const CFSocketContext *context, CFTimeInterval timeout); -/* CFSocketCreateWithSignature creates a socket of the requested type and binds its address (using CFSocketSetAddress) to the requested address. If this fails, it returns NULL. CFSocketCreateConnectedToSignature creates a socket suitable for connecting to the requested type and address, and connects it (using CFSocketConnectToAddress). If this fails, it returns NULL. */ +/* CFSocketCreateConnectedToSocketSignature() creates a socket suitable for connecting to the requested type and address, and connects it (using CFSocketConnectToAddress()). If this fails, it returns NULL. */ CF_EXPORT CFSocketError CFSocketSetAddress(CFSocketRef s, CFDataRef address); CF_EXPORT CFSocketError CFSocketConnectToAddress(CFSocketRef s, CFDataRef address, CFTimeInterval timeout); @@ -193,12 +185,11 @@ CF_EXPORT CFSocketNativeHandle CFSocketGetNative(CFSocketRef s); CF_EXPORT CFRunLoopSourceRef CFSocketCreateRunLoopSource(CFAllocatorRef allocator, CFSocketRef s, CFIndex order); -#if MAC_OS_X_VERSION_10_2 <= MAC_OS_X_VERSION_MAX_ALLOWED CF_EXPORT CFOptionFlags CFSocketGetSocketFlags(CFSocketRef s); CF_EXPORT void CFSocketSetSocketFlags(CFSocketRef s, CFOptionFlags flags); CF_EXPORT void CFSocketDisableCallBacks(CFSocketRef s, CFOptionFlags callBackTypes); CF_EXPORT void CFSocketEnableCallBacks(CFSocketRef s, CFOptionFlags callBackTypes); -#endif + /* For convenience, a function is provided to send data using the socket with a timeout. The timeout will be used only if the specified value is positive. The address should be left NULL if the socket is already connected. */ CF_EXPORT CFSocketError CFSocketSendData(CFSocketRef s, CFDataRef address, CFDataRef data, CFTimeInterval timeout); @@ -241,6 +232,7 @@ CF_EXPORT const CFStringRef kCFSocketRegisterCommand; CF_EXPORT const CFStringRef kCFSocketRetrieveCommand; CF_EXTERN_C_END +CF_IMPLICIT_BRIDGING_DISABLED #endif /* ! __COREFOUNDATION_CFSOCKET__ */