use std::os::raw::{c_int, c_void};
use crate::base::{
Boolean, CFAllocatorRef, CFIndex, CFOptionFlags, CFTypeID, CFTypeRef, SInt32, UInt32, UInt8,
};
use crate::error::CFErrorRef;
use crate::runloop::CFRunLoopRef;
use crate::socket::{CFSocketNativeHandle, CFSocketSignature};
use crate::string::CFStringRef;
use crate::url::CFURLRef;
#[repr(C)]
pub struct __CFReadStream(c_void);
#[repr(C)]
pub struct __CFWriteStream(c_void);
pub type CFReadStreamRef = *mut __CFReadStream;
pub type CFWriteStreamRef = *mut __CFWriteStream;
pub type CFStreamPropertyKey = CFStringRef;
pub type CFStreamStatus = CFIndex;
pub type CFStreamEventType = CFOptionFlags;
pub type CFStreamErrorDomain = CFIndex;
#[repr(C)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct CFStreamError {
pub domain: CFIndex,
pub error: SInt32,
}
pub const kCFStreamStatusNotOpen: CFStreamStatus = 0;
pub const kCFStreamStatusOpening: CFStreamStatus = 1;
pub const kCFStreamStatusOpen: CFStreamStatus = 2;
pub const kCFStreamStatusReading: CFStreamStatus = 3;
pub const kCFStreamStatusWriting: CFStreamStatus = 4;
pub const kCFStreamStatusAtEnd: CFStreamStatus = 5;
pub const kCFStreamStatusClosed: CFStreamStatus = 6;
pub const kCFStreamStatusError: CFStreamStatus = 7;
pub const kCFStreamErrorDomainCustom: CFStreamErrorDomain = -1;
pub const kCFStreamErrorDomainPOSIX: CFStreamErrorDomain = 1;
pub const kCFStreamErrorDomainMacOSStatus: CFStreamErrorDomain = 2;
pub const kCFStreamEventNone: CFStreamEventType = 0;
pub const kCFStreamEventOpenCompleted: CFStreamEventType = 1;
pub const kCFStreamEventHasBytesAvailable: CFStreamEventType = 2;
pub const kCFStreamEventCanAcceptBytes: CFStreamEventType = 4;
pub const kCFStreamEventErrorOccurred: CFStreamEventType = 8;
pub const kCFStreamEventEndEncountered: CFStreamEventType = 16;
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct CFStreamClientContext {
pub version: CFIndex,
pub info: *mut c_void,
pub retain: extern "C" fn(info: *const c_void) -> *const c_void,
pub release: extern "C" fn(info: *const c_void),
pub copyDescription: extern "C" fn(info: *const c_void) -> CFStringRef,
}
pub type CFReadStreamClientCallBack = extern "C" fn(
stream: CFReadStreamRef,
_type: CFStreamEventType,
clientCallBackInfo: *mut c_void,
);
pub type CFWriteStreamClientCallBack = extern "C" fn(
stream: CFWriteStreamRef,
_type: CFStreamEventType,
clientCallBackInfo: *mut c_void,
);
extern "C" {
pub static kCFStreamPropertyAppendToFile: CFStreamPropertyKey;
pub static kCFStreamPropertyDataWritten: CFStreamPropertyKey;
pub static kCFStreamPropertyFileCurrentOffset: CFStreamPropertyKey;
pub static kCFStreamPropertySocketNativeHandle: CFStreamPropertyKey;
pub static kCFStreamPropertySocketRemoteHostName: CFStreamPropertyKey;
pub static kCFStreamPropertySocketRemotePortNumber: CFStreamPropertyKey;
pub static kCFStreamPropertyShouldCloseNativeSocket: CFStringRef;
pub static kCFStreamPropertySocketSecurityLevel: CFStringRef;
pub static kCFStreamSocketSecurityLevelNone: CFStringRef;
pub static kCFStreamSocketSecurityLevelSSLv2: CFStringRef;
pub static kCFStreamSocketSecurityLevelSSLv3: CFStringRef;
pub static kCFStreamSocketSecurityLevelTLSv1: CFStringRef;
pub static kCFStreamSocketSecurityLevelNegotiatedSSL: CFStringRef;
pub static kCFStreamPropertySOCKSProxy: CFStringRef;
pub static kCFStreamPropertySOCKSProxyHost: CFStringRef;
pub static kCFStreamPropertySOCKSProxyPort: CFStringRef;
pub static kCFStreamPropertySOCKSVersion: CFStringRef;
pub static kCFStreamSocketSOCKSVersion4: CFStringRef;
pub static kCFStreamSocketSOCKSVersion5: CFStringRef;
pub static kCFStreamPropertySOCKSUser: CFStringRef;
pub static kCFStreamPropertySOCKSPassword: CFStringRef;
pub static kCFStreamErrorDomainSOCKS: c_int;
pub static kCFStreamErrorDomainSSL: c_int;
pub fn CFStreamCreatePairWithPeerSocketSignature(
alloc: CFAllocatorRef,
signature: *const CFSocketSignature,
readStream: *mut CFReadStreamRef,
writeStream: *mut CFWriteStreamRef,
); pub fn CFStreamCreatePairWithSocketToHost(
alloc: CFAllocatorRef,
host: CFStringRef,
port: UInt32,
readStream: *mut CFReadStreamRef,
writeStream: *mut CFWriteStreamRef,
); pub fn CFStreamCreatePairWithSocket(
alloc: CFAllocatorRef,
sock: CFSocketNativeHandle,
readStream: *mut CFReadStreamRef,
writeStream: *mut CFWriteStreamRef,
); pub fn CFStreamCreateBoundPair(
alloc: CFAllocatorRef,
readStream: *mut CFReadStreamRef,
writeStream: *mut CFWriteStreamRef,
transferBufferSize: CFIndex,
);
pub fn CFReadStreamCreateWithBytesNoCopy(
alloc: CFAllocatorRef,
bytes: *const UInt8,
length: CFIndex,
bytesDeallocator: CFAllocatorRef,
) -> CFReadStreamRef;
pub fn CFReadStreamCreateWithFile(alloc: CFAllocatorRef, fileURL: CFURLRef) -> CFReadStreamRef;
pub fn CFReadStreamClose(stream: CFReadStreamRef);
pub fn CFReadStreamOpen(stream: CFReadStreamRef) -> Boolean;
pub fn CFReadStreamRead(
stream: CFReadStreamRef,
buffer: *mut UInt8,
bufferLength: CFIndex,
) -> CFIndex;
pub fn CFReadStreamScheduleWithRunLoop(
stream: CFReadStreamRef,
runLoop: CFRunLoopRef,
runLoopMode: CFStringRef,
);
pub fn CFReadStreamUnscheduleFromRunLoop(
stream: CFReadStreamRef,
runLoop: CFRunLoopRef,
runLoopMode: CFStringRef,
);
pub fn CFReadStreamCopyProperty(
stream: CFReadStreamRef,
propertyName: CFStreamPropertyKey,
) -> CFTypeRef;
pub fn CFReadStreamGetBuffer(
stream: CFReadStreamRef,
maxBytesToRead: CFIndex,
numBytesRead: *mut CFIndex,
) -> *const UInt8;
pub fn CFReadStreamCopyError(stream: CFReadStreamRef) -> CFErrorRef;
pub fn CFReadStreamGetError(stream: CFReadStreamRef) -> CFStreamError; pub fn CFReadStreamGetStatus(stream: CFReadStreamRef) -> CFStreamStatus;
pub fn CFReadStreamHasBytesAvailable(stream: CFReadStreamRef) -> Boolean;
pub fn CFReadStreamSetClient(
stream: CFReadStreamRef,
streamEvents: CFOptionFlags,
clientCB: CFReadStreamClientCallBack,
clientContext: *mut CFStreamClientContext,
) -> Boolean;
pub fn CFReadStreamSetProperty(
stream: CFReadStreamRef,
propertyName: CFStreamPropertyKey,
propertyValue: CFTypeRef,
) -> Boolean;
pub fn CFReadStreamGetTypeID() -> CFTypeID;
pub fn CFWriteStreamCreateWithAllocatedBuffers(
alloc: CFAllocatorRef,
bufferAllocator: CFAllocatorRef,
) -> CFWriteStreamRef;
pub fn CFWriteStreamCreateWithBuffer(
alloc: CFAllocatorRef,
buffer: *mut UInt8,
bufferCapacity: CFIndex,
) -> CFWriteStreamRef;
pub fn CFWriteStreamCreateWithFile(
alloc: CFAllocatorRef,
fileURL: CFURLRef,
) -> CFWriteStreamRef;
pub fn CFWriteStreamClose(stream: CFWriteStreamRef);
pub fn CFWriteStreamOpen(stream: CFWriteStreamRef) -> Boolean;
pub fn CFWriteStreamWrite(
stream: CFWriteStreamRef,
buffer: *const UInt8,
bufferLength: CFIndex,
) -> CFIndex;
pub fn CFWriteStreamScheduleWithRunLoop(
stream: CFWriteStreamRef,
runLoop: CFRunLoopRef,
runLoopMode: CFStringRef,
);
pub fn CFWriteStreamUnscheduleFromRunLoop(
stream: CFWriteStreamRef,
runLoop: CFRunLoopRef,
runLoopMode: CFStringRef,
);
pub fn CFWriteStreamCanAcceptBytes(stream: CFWriteStreamRef) -> Boolean;
pub fn CFWriteStreamCopyProperty(
stream: CFWriteStreamRef,
propertyName: CFStreamPropertyKey,
) -> CFTypeRef;
pub fn CFWriteStreamCopyError(stream: CFWriteStreamRef) -> CFErrorRef;
pub fn CFWriteStreamGetError(stream: CFWriteStreamRef) -> CFStreamError; pub fn CFWriteStreamGetStatus(stream: CFWriteStreamRef) -> CFStreamStatus;
pub fn CFWriteStreamSetClient(
stream: CFWriteStreamRef,
streamEvents: CFOptionFlags,
clientCB: CFWriteStreamClientCallBack,
clientContext: *mut CFStreamClientContext,
) -> Boolean;
pub fn CFWriteStreamSetProperty(
stream: CFWriteStreamRef,
propertyName: CFStreamPropertyKey,
propertyValue: CFTypeRef,
) -> Boolean;
pub fn CFWriteStreamGetTypeID() -> CFTypeID;
}