diff dstep/corefoundation/CFSocket.d @ 11:07194b026fa4

Added bindings to a couple of frameworks, new license + some other things
author Jacob Carlborg <doob@me.com>
date Sat, 01 Aug 2009 15:03:28 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dstep/corefoundation/CFSocket.d	Sat Aug 01 15:03:28 2009 +0200
@@ -0,0 +1,110 @@
+/**
+ * Copyright: Copyright (c) 2009 Jacob Carlborg.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Jul 12, 2009 
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
+ */
+module dstep.corefoundation.CFSocket;
+
+import dstep.corefoundation.CFBase;
+import dstep.corefoundation.CFData;
+import dstep.corefoundation.CFRunLoop;
+import dstep.objc.bridge.Bridge;
+import dstep.objc.objc : id;
+//import dstep.winsock2;
+
+alias int CFSocketNativeHandle;
+struct __CFSocket;
+alias __CFSocket* CFSocketRef;
+alias int CFSocketError;
+alias uint CFSocketCallBackType;
+
+extern (C)
+{
+	alias void function (CFSocketRef, uint, CFDataRef, void*, void*) CFSocketCallBack;
+}
+
+extern (C)
+{
+	extern
+	{
+		const CFStringRef kCFSocketCommandKey;
+		const CFStringRef kCFSocketNameKey;
+		const CFStringRef kCFSocketValueKey;
+		const CFStringRef kCFSocketResultKey;
+		const CFStringRef kCFSocketErrorKey;
+		const CFStringRef kCFSocketRegisterCommand;
+		const CFStringRef kCFSocketRetrieveCommand;
+	}
+}
+
+enum
+{
+	kCFSocketSuccess = 0,
+	kCFSocketError = -1,
+	kCFSocketTimeout = -2
+}
+
+enum
+{
+	kCFSocketNoCallBack = 0,
+	kCFSocketReadCallBack = 1,
+	kCFSocketAcceptCallBack = 2,
+	kCFSocketDataCallBack = 3,
+	kCFSocketConnectCallBack = 4,
+	kCFSocketWriteCallBack = 8
+}
+
+enum
+{
+	kCFSocketAutomaticallyReenableReadCallBack = 1,
+	kCFSocketAutomaticallyReenableAcceptCallBack = 2,
+	kCFSocketAutomaticallyReenableDataCallBack = 3,
+	kCFSocketAutomaticallyReenableWriteCallBack = 8,
+	kCFSocketCloseOnInvalidate = 128
+}
+
+struct CFSocketSignature
+{
+	int protocolFamily;
+	int socketType;
+	int protocol;
+	CFDataRef address;
+}
+
+
+struct CFSocketContext
+{
+	int version_;
+	void* info;
+}
+
+extern (C)
+{
+	uint CFSocketGetTypeID ();
+	CFSocketRef CFSocketCreate (CFAllocatorRef allocator, int protocolFamily, int socketType, int protocol, uint callBackTypes, CFSocketCallBack* callout, CFSocketContext* context);
+	CFSocketRef CFSocketCreateWithNative (CFAllocatorRef allocator, int sock, uint callBackTypes, CFSocketCallBack* callout, CFSocketContext* context);
+	CFSocketRef CFSocketCreateWithSocketSignature (CFAllocatorRef allocator, CFSocketSignature* signature, uint callBackTypes, CFSocketCallBack* callout, CFSocketContext* context);
+	CFSocketRef CFSocketCreateConnectedToSocketSignature (CFAllocatorRef allocator, CFSocketSignature* signature, uint callBackTypes, CFSocketCallBack* callout, CFSocketContext* context, double timeout);
+	int CFSocketSetAddress (CFSocketRef s, CFDataRef address);
+	int CFSocketConnectToAddress (CFSocketRef s, CFDataRef address, double timeout);
+	void CFSocketInvalidate (CFSocketRef s);
+	ubyte CFSocketIsValid (CFSocketRef s);
+	CFDataRef CFSocketCopyAddress (CFSocketRef s);
+	CFDataRef CFSocketCopyPeerAddress (CFSocketRef s);
+	void CFSocketGetContext (CFSocketRef s, CFSocketContext* context);
+	int CFSocketGetNative (CFSocketRef s);
+	CFRunLoopSourceRef CFSocketCreateRunLoopSource (CFAllocatorRef allocator, CFSocketRef s, int order);
+	uint CFSocketGetSocketFlags (CFSocketRef s);
+	void CFSocketSetSocketFlags (CFSocketRef s, uint flags);
+	void CFSocketDisableCallBacks (CFSocketRef s, uint callBackTypes);
+	void CFSocketEnableCallBacks (CFSocketRef s, uint callBackTypes);
+	int CFSocketSendData (CFSocketRef s, CFDataRef address, CFDataRef data, double timeout);
+	int CFSocketRegisterValue (CFSocketSignature* nameServerSignature, double timeout, CFStringRef name, void* value);
+	int CFSocketCopyRegisteredValue (CFSocketSignature* nameServerSignature, double timeout, CFStringRef name, CFPropertyListRef* value, CFDataRef* nameServerAddress);
+	int CFSocketRegisterSocketSignature (CFSocketSignature* nameServerSignature, double timeout, CFStringRef name, CFSocketSignature* signature);
+	int CFSocketCopyRegisteredSocketSignature (CFSocketSignature* nameServerSignature, double timeout, CFStringRef name, CFSocketSignature* signature, CFDataRef* nameServerAddress);
+	int CFSocketUnregister (CFSocketSignature* nameServerSignature, double timeout, CFStringRef name);
+	void CFSocketSetDefaultNameRegistryPortNumber (ushort port);
+	ushort CFSocketGetDefaultNameRegistryPortNumber ();
+}
\ No newline at end of file