#if !defined(__CFNETWORK_CFCONNECTION__)
#define __CFNETWORK_CFCONNECTION__ 1
#include <CFNetwork/CFNetwork.h>
#include "CFNetworkInternal.h"
#include <CoreFoundation/CFStreamAbstract.h>
#include <CFNetwork/CFSocketStream.h>
#include <CoreFoundation/CFRuntime.h>
#include <sys/types.h>
#include <AvailabilityMacros.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct __CFNetConnection* _CFNetConnectionRef;
enum _CFNetConnectionState {
kNotQueued = 0,
kQueued = 1,
kTransmittingRequest = 2,
kWaitingForResponse = 3,
kReceivingResponse = 4,
kFinished = 5,
kCancelled = 6,
kOrphaned = 7
};
typedef enum _CFNetConnectionState _CFNetConnectionState;
typedef CALLBACK_API_C( const void *, _CFNetConnectionCreateCallBack )(CFAllocatorRef alloc, const void *info);
typedef CALLBACK_API_C( void , _CFNetConnectionFinalizeCallBack )(CFAllocatorRef alloc, const void *info);
typedef CALLBACK_API_C( CFStreamError , _CFNetConnectionCreateStreamsCallBack )(CFAllocatorRef allocator, const void *info, CFWriteStreamRef *requestStream, CFReadStreamRef *responseStream);
typedef CALLBACK_API_C( void , _CFNetConnectionStateChangedCallBack )(void *request, int newState, CFStreamError *err, _CFNetConnectionRef connection, const void *info);
typedef CALLBACK_API_C( void , _CFNetConnectionTransmitRequest )(void *request, _CFNetConnectionRef connection, const void *info);
typedef CALLBACK_API_C( void , _CFNetConnectionReceiveResponse )(void *request, _CFNetConnectionRef connection, const void *info);
typedef CALLBACK_API_C( void , _CFNetConnectionResponseStreamCallBack )(void *request, CFReadStreamRef stream, CFStreamEventType eventType, _CFNetConnectionRef conn, const void *info);
typedef CALLBACK_API_C( void , _CFNetConnectionRequestStreamCallBack )(void *request, CFWriteStreamRef stream, CFStreamEventType eventType, _CFNetConnectionRef conn, const void *info);
typedef CALLBACK_API_C( CFArrayRef , _CFNetConnectionRunLoopArrayCallBack )(void *request, _CFNetConnectionRef conn, const void *info);
struct _CFNetConnectionCallBacks {
CFIndex version;
_CFNetConnectionCreateCallBack create;
_CFNetConnectionFinalizeCallBack finalize;
_CFNetConnectionCreateStreamsCallBack createConnectionStreams;
_CFNetConnectionStateChangedCallBack requestStateChanged;
_CFNetConnectionTransmitRequest transmitRequest;
_CFNetConnectionReceiveResponse receiveResponse;
_CFNetConnectionResponseStreamCallBack responseStreamCallBack;
_CFNetConnectionRequestStreamCallBack requestStreamCallBack;
_CFNetConnectionRunLoopArrayCallBack runLoopAndModesArrayForRequest;
};
typedef struct _CFNetConnectionCallBacks _CFNetConnectionCallBacks;
extern CFTypeID
_CFNetConnectionGetTypeID(void) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
extern const void *
_CFNetConnectionGetInfoPointer(_CFNetConnectionRef conn) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
extern _CFNetConnectionRef
_CFNetConnectionCreate(
CFAllocatorRef alloc,
const void * info,
const _CFNetConnectionCallBacks * callBacks,
Boolean isThreadSafe) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
extern Boolean
_CFNetConnectionEnqueue(
_CFNetConnectionRef conn,
void * req) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
extern Boolean
_CFNetConnectionDequeue(
_CFNetConnectionRef conn,
void * req) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
extern void *
_CFNetConnectionGetCurrentRequest(_CFNetConnectionRef conn) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
extern void
_CFNetConnectionReplaceRequest(
_CFNetConnectionRef conn,
void * oldReq,
void * newReq) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
extern CFReadStreamRef
_CFNetConnectionGetResponseStream(_CFNetConnectionRef conn) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
extern CFWriteStreamRef
_CFNetConnectionGetRequestStream(_CFNetConnectionRef conn) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
extern void
_CFNetConnectionResponseIsComplete(
_CFNetConnectionRef conn,
void * req) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
extern void
_CFNetConnectionRequestIsComplete(
_CFNetConnectionRef conn,
void * req) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
extern void
_CFNetConnectionErrorOccurred(
_CFNetConnectionRef conn,
CFStreamError * err) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
extern void
_CFNetConnectionLost(_CFNetConnectionRef conn) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
extern void
_CFNetConnectionSetShouldPipeline(
_CFNetConnectionRef conn,
Boolean shouldPipeline) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
extern CFAbsoluteTime
_CFNetConnectionGetLastAccessTime(_CFNetConnectionRef arg);
extern int
_CFNetConnectionGetQueueDepth(_CFNetConnectionRef conn);
extern void
_CFNetConnectionSetAllowsNewRequests(
_CFNetConnectionRef conn,
Boolean allowRequests) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
extern Boolean
_CFNetConnectionWillEnqueueRequests(_CFNetConnectionRef conn) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
extern int
_CFNetConnectionGetState(
_CFNetConnectionRef conn,
Boolean advanceConnection,
void * req) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
extern void
_CFNetConnectionSchedule(
_CFNetConnectionRef conn,
void * req,
CFRunLoopRef rl,
CFStringRef mode) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
extern void
_CFNetConnectionUnschedule(
_CFNetConnectionRef conn,
void * req,
CFRunLoopRef rl,
CFStringRef mode) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
extern Boolean
_CFNetConnectionIsEmpty(_CFNetConnectionRef conn) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
typedef struct __CFNetConnectionCache * CFNetConnectionCacheRef;
typedef struct __CFNetConnectionCacheKey* _CFNetConnectionCacheKey;
CFNetConnectionCacheRef createConnectionCache();
#if defined(__WIN32__)
void releaseConnectionCache(CFNetConnectionCacheRef cache);
#endif
void lockConnectionCache(CFNetConnectionCacheRef cache);
void unlockConnectionCache(CFNetConnectionCacheRef cache);
extern
_CFNetConnectionRef findOrCreateNetConnection(CFNetConnectionCacheRef connectionCache, CFAllocatorRef allocator, const _CFNetConnectionCallBacks *callbacks, const void *info, _CFNetConnectionCacheKey key, Boolean persistent, CFDictionaryRef connectionProperties); extern
void removeFromConnectionCache(CFNetConnectionCacheRef cache, _CFNetConnectionRef conn, _CFNetConnectionCacheKey key);
const void *connCacheKeyRetain(CFAllocatorRef allocator, const void *value);
void connCacheKeyRelease(CFAllocatorRef allocator, const void *value);
_CFNetConnectionCacheKey createConnectionCacheKey(CFStringRef host, SInt32 port, UInt32 connType, CFDictionaryRef properties);
void releaseConnectionCacheKey(_CFNetConnectionCacheKey theKey);
void getValuesFromKey(const _CFNetConnectionCacheKey theKey, CFStringRef *host, SInt32 *port, UInt32 *connType, CFDictionaryRef *properties);
#ifdef DEBUG
void printKey(_CFNetConnectionCacheKey key);
#endif
#if defined(__cplusplus)
}
#endif
#endif