Mercurial > projects > dstep
diff dstep/coreservices/osservices/OpenTransport.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/coreservices/osservices/OpenTransport.d Sat Aug 01 15:03:28 2009 +0200 @@ -0,0 +1,813 @@ +/** + * Copyright: Copyright (c) 2009 Jacob Carlborg. + * Authors: Jacob Carlborg + * Version: Initial created: Jul 22, 2009 + * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) + */ +module dstep.coreservices.osservices.OpenTransport; + +//import dstep.AvailabilityMacros; +import dstep.coreservices.carboncore.MacErrors; +import dstep.coreservices.carboncore.MacTypes; +import dstep.coreservices.carboncore.MixedMode; +import dstep.internal.Version; +import dstep.objc.bridge.TypeEncoding; +//import dstep.stddef; + +struct OTConfiguration; +struct OpaqueOTClientContextPtr; + +struct TOptionHeader +{ + uint len; + uint level; + uint name; + uint status; +} + +alias ubyte OTUInt8Param; +alias ushort OTUInt16Param; +alias short OTSInt16Param; +alias byte OTSInt8Param; +alias ubyte OTBooleanParam; +alias ubyte uchar_p; +alias ushort ushort_p; +alias short short_p; +alias byte char_p; +alias ubyte boolean_p; +alias uint OTByteCount; +alias uint OTItemCount; +alias int OTInt32; +alias uint OTUInt32; +alias int int_t; +alias uint uint_t; +alias uint OTTimeout; +alias int OTSequence; +alias int OTNameID; +alias int OTReason; +alias uint OTQLen; +alias char* OTClientName; +alias int OTCommand; +alias void* OTClient; +alias uint OTOpenFlags; +alias ushort OTUnixErr; +alias ushort OTXTIErr; +alias int OTResult; +alias ushort OTAddressType; +alias uint OTStructType; +alias uint OTFieldsType; +alias uint OTFlags; +alias uint OTBand; +alias void* ProviderRef; +alias void* EndpointRef; +alias void* MapperRef; +alias uint OTEventCode; +alias OTNotifyProcPtr OTNotifyUPP; +alias uint OTXTILevel; +alias uint OTXTIName; +alias uint OTXTIStates; +alias OTConfiguration* OTConfigurationRef; +alias uint OTServiceType; +alias int OTDataSize; +alias uint OTPortRef; +alias OTPortRef* OTPortRefPtr; +alias ubyte OTBusType; +alias ushort OTDeviceType; +alias ushort OTSlotNumber; +alias OpaqueOTClientContextPtr* OTClientContextPtr; +alias uint OTInitializationFlags; +alias OTProcessProcPtr OTProcessUPP; +alias int OTDeferredTaskRef; +alias int OTSystemTaskRef; +alias UnsignedWide OTTimeStamp; +alias OTListSearchProcPtr OTListSearchUPP; +alias ubyte OTLock; + +extern (C) +{ + alias ubyte function (void*, OTLink*) OTListSearchProcPtr; + alias void function (void*) OTProcessProcPtr; + alias void function (void*, uint, int, void*) OTNotifyProcPtr; +} + +// This is needed otherwise the enums will fail compiling with gdc +version (GNU) +{ + private + { + const __kOTCFMClass = getOSType!("otan"); + } +} + +enum +{ + kOTCFMClass = getOSType!("otan") +} + +enum +{ + kO_ASYNC = 0x01, + kO_NDELAY = 0x04, + kO_NONBLOCK = 0x04 +} + +enum +{ + TSUCCESS = 0, + TBADADDR = 1, + TBADOPT = 2, + TACCES = 3, + TBADF = 4, + TNOADDR = 5, + TOUTSTATE = 6, + TBADSEQ = 7, + TSYSERR = 8, + TLOOK = 9, + TBADDATA = 10, + TBUFOVFLW = 11, + TFLOW = 12, + TNODATA = 13, + TNODIS = 14, + TNOUDERR = 15, + TBADFLAG = 16, + TNOREL = 17, + TNOTSUPPORT = 18, + TSTATECHNG = 19, + TNOSTRUCTYPE = 20, + TBADNAME = 21, + TBADQLEN = 22, + TADDRBUSY = 23, + TINDOUT = 24, + TPROVMISMATCH = 25, + TRESQLEN = 26, + TRESADDR = 27, + TQFULL = 28, + TPROTO = 29, + TBADSYNC = 30, + TCANCELED = 31, + TLASTXTIERROR = 31 +} + +enum +{ + kOTGenericName = 0 +} + +enum +{ + T_BIND = 1, + T_OPTMGMT = 2, + T_CALL = 3, + T_DIS = 4, + T_UNITDATA = 5, + T_UDERROR = 6, + T_INFO = 7, + T_REPLYDATA = 8, + T_REQUESTDATA = 9, + T_UNITREQUEST = 10, + T_UNITREPLY = 11 +} + +enum +{ + T_ADDR = 0x01, + T_OPT = 0x02, + T_UDATA = 0x04, + T_ALL = 0xFFFF +} + +enum +{ + T_MORE = 0x0001, + T_EXPEDITED = 0x0002, + T_ACKNOWLEDGED = 0x0004, + T_PARTIALDATA = 0x0008, + T_NORECEIPT = 0x0010, + T_TIMEDOUT = 0x0020 +} + +enum +{ + T_NEGOTIATE = 0x0004, + T_CHECK = 0x0008, + T_DEFAULT = 0x0010, + T_CURRENT = 0x0080 +} + +enum +{ + T_SUCCESS = 0x0020, + T_FAILURE = 0x0040, + T_PARTSUCCESS = 0x0100, + T_READONLY = 0x0200, + T_NOTSUPPORT = 0x0400 +} + +enum +{ + T_LISTEN = 0x0001, + T_CONNECT = 0x0002, + T_DATA = 0x0004, + T_EXDATA = 0x0008, + T_DISCONNECT = 0x0010, + T_ERROR = 0x0020, + T_UDERR = 0x0040, + T_ORDREL = 0x0080, + T_GODATA = 0x0100, + T_GOEXDATA = 0x0200, + T_REQUEST = 0x0400, + T_REPLY = 0x0800, + T_PASSCON = 0x1000, + T_RESET = 0x2000, + kPRIVATEEVENT = 0x10000000, + kCOMPLETEEVENT = 0x20000000, + T_BINDCOMPLETE = 0x20000001, + T_UNBINDCOMPLETE = 0x20000002, + T_ACCEPTCOMPLETE = 0x20000003, + T_REPLYCOMPLETE = 0x20000004, + T_DISCONNECTCOMPLETE = 0x20000005, + T_OPTMGMTCOMPLETE = 0x20000006, + T_OPENCOMPLETE = 0x20000007, + T_GETPROTADDRCOMPLETE = 0x20000008, + T_RESOLVEADDRCOMPLETE = 0x20000009, + T_GETINFOCOMPLETE = 0x2000000A, + T_SYNCCOMPLETE = 0x2000000B, + T_MEMORYRELEASED = 0x2000000C, + T_REGNAMECOMPLETE = 0x2000000D, + T_DELNAMECOMPLETE = 0x2000000E, + T_LKUPNAMECOMPLETE = 0x2000000F, + T_LKUPNAMERESULT = 0x20000010, + kOTSyncIdleEvent = 0x20000011, + kSTREAMEVENT = 0x21000000, + kOTReservedEvent1 = 0x21000001, + kGetmsgEvent = 0x21000002, + kStreamReadEvent = 0x21000003, + kStreamWriteEvent = 0x21000004, + kStreamIoctlEvent = 0x21000005, + kOTReservedEvent2 = 0x21000006, + kStreamOpenEvent = 0x21000007, + kPollEvent = 0x21000008, + kOTReservedEvent3 = 0x21000009, + kOTReservedEvent4 = 0x2100000A, + kOTReservedEvent5 = 0x2100000B, + kOTReservedEvent6 = 0x2100000C, + kOTReservedEvent7 = 0x2100000D, + kOTReservedEvent8 = 0x2100000E, + kSIGNALEVENT = 0x22000000, + kPROTOCOLEVENT = 0x23000000, + kOTProviderIsDisconnected = 0x23000001, + kOTProviderIsReconnected = 0x23000002, + kOTProviderWillClose = 0x24000001, + kOTProviderIsClosed = 0x24000002, + kOTPortDisabled = 0x25000001, + kOTPortEnabled = 0x25000002, + kOTPortOffline = 0x25000003, + kOTPortOnline = 0x25000004, + kOTClosePortRequest = 0x25000005, + kOTYieldPortRequest = 0x25000005, + kOTNewPortRegistered = 0x25000006, + kOTPortNetworkChange = 0x25000007, + kOTConfigurationChanged = 0x26000001, + kOTSystemSleep = 0x26000002, + kOTSystemShutdown = 0x26000003, + kOTSystemAwaken = 0x26000004, + kOTSystemIdle = 0x26000005, + kOTSystemSleepPrep = 0x26000006, + kOTSystemShutdownPrep = 0x26000007, + kOTSystemAwakenPrep = 0x26000008, + kOTStackIsLoading = 0x27000001, + kOTStackWasLoaded = 0x27000002, + kOTStackIsUnloading = 0x27000003 +} + +enum +{ + kOTDisablePortEvent = 0x21000001, + kStreamCloseEvent = 0x21000006, + kBackgroundStreamEvent = 0x21000009, + kIoctlRecvFdEvent = 0x2100000A, + kOTTryShutdownEvent = 0x2100000B, + kOTScheduleTerminationEvent = 0x2100000C, + kOTEnablePortEvent = 0x2100000D, + kOTNewPortRegisteredEvent = 0x2100000E, + kOTPortOfflineEvent = 0x2100000F, + kOTPortOnlineEvent = 0x21000010, + kOTPortNetworkChangeEvent = 0x21000011 +} + +enum +{ + kSIGHUP = 1, + kSIGURG = 16, + kSIGPOLL = 30 +} + +enum +{ + XTI_GENERIC = 0xFFFF +} + +enum +{ + XTI_DEBUG = 0x0001, + XTI_LINGER = 0x0080, + XTI_RCVBUF = 0x1002, + XTI_RCVLOWAT = 0x1004, + XTI_SNDBUF = 0x1001, + XTI_SNDLOWAT = 0x1003, + XTI_PROTOTYPE = 0x1005, + OPT_CHECKSUM = 0x0600, + OPT_RETRYCNT = 0x0601, + OPT_INTERVAL = 0x0602, + OPT_ENABLEEOM = 0x0603, + OPT_SELFSEND = 0x0604, + OPT_SERVERSTATUS = 0x0605, + OPT_ALERTENABLE = 0x0606, + OPT_KEEPALIVE = 0x0008 +} + +enum +{ + MIOC_STREAMIO = 'A', + MIOC_TMOD = 'a', + MIOC_STRLOG = 'b', + MIOC_ND = 'c', + MIOC_ECHO = 'd', + MIOC_TLI = 'e', + MIOC_RESERVEDf = 'f', + MIOC_SAD = 'g', + MIOC_ARP = 'h', + MIOC_HAVOC = 'H', + MIOC_RESERVEDi = 'i', + MIOC_SIOC = 'j', + MIOC_TCP = 'k', + MIOC_DLPI = 'l', + MIOC_SOCKETS = 'm', + MIOC_IPX = 'o', + MIOC_OT = 'O', + MIOC_ATALK = 'T', + MIOC_SRL = 'U', + MIOC_RESERVEDp = 'p', + MIOC_RESERVEDr = 'r', + MIOC_RESERVEDs = 's', + MIOC_CFIG = 'z' +} + +enum +{ + I_OTGetMiscellaneousEvents = ((MIOC_OT << 8) | 1), + I_OTSetFramingType = ((MIOC_OT << 8) | 2), + kOTGetFramingValue = cast(uint)0xFFFFFFFF, + I_OTSetRawMode = ((MIOC_OT << 8) | 3), + kOTSetRecvMode = 0x01, + kOTSendErrorPacket = 0x02, + I_OTConnect = ((MIOC_OT << 8) | 4), + I_OTDisconnect = ((MIOC_OT << 8) | 5), + I_OTScript = ((MIOC_OT << 8) | 6) +} + +enum +{ + T_UNINIT = 0, + T_UNBND = 1, + T_IDLE = 2, + T_OUTCON = 3, + T_INCON = 4, + T_DATAXFER = 5, + T_OUTREL = 6, + T_INREL = 7 +} + +static if (D_LP64) +{ + enum : ulong + { + T_YES = 1, + T_NO = 0, + T_UNUSED = -1, + kT_NULL = 0, + T_ABSREQ = 0x8000 + } +} + +else +{ + enum : uint + { + T_YES = 1, + T_NO = 0, + T_UNUSED = -1, + kT_NULL = 0, + T_ABSREQ = 0x8000 + } +} + +enum +{ + kT_UNSPEC = cast(uint)0xFFFFFFFD, + T_ALLOPT = 0 +} + +enum +{ + kOTOptionHeaderSize = TOptionHeader.sizeof, + kOTBooleanOptionDataSize = uint.sizeof, + kOTBooleanOptionSize = kOTOptionHeaderSize + kOTBooleanOptionDataSize, + kOTOneByteOptionSize = kOTOptionHeaderSize + 1, + kOTTwoByteOptionSize = kOTOptionHeaderSize + 2, + kOTFourByteOptionSize = kOTOptionHeaderSize + uint.sizeof +} + +enum +{ + T_COTS = 1, + T_COTS_ORD = 2, + T_CLTS = 3, + T_TRANS = 5, + T_TRANS_ORD = 6, + T_TRANS_CLTS = 7 +} + +enum +{ + T_SENDZERO = 0x0001, + T_XPG4_1 = 0x0002, + T_CAN_SUPPORT_MDATA = 0x10000000, + T_CAN_RESOLVE_ADDR = 0x40000000, + T_CAN_SUPPLY_MIB = 0x20000000 +} + +enum +{ + T_INFINITE = -1, + T_INVALID = -2 +} + +enum +{ + kOTInvalidPortRef = 0 +} + +enum +{ + kOTUnknownBusPort = 0, + kOTMotherboardBus = 1, + kOTNuBus = 2, + kOTPCIBus = 3, + kOTGeoPort = 4, + kOTPCCardBus = 5, + kOTFireWireBus = 6, + kOTLastBusIndex = 15 +} + +enum +{ + kOTNoDeviceType = 0, + kOTADEVDevice = 1, + kOTMDEVDevice = 2, + kOTLocalTalkDevice = 3, + kOTIRTalkDevice = 4, + kOTTokenRingDevice = 5, + kOTISDNDevice = 6, + kOTATMDevice = 7, + kOTSMDSDevice = 8, + kOTSerialDevice = 9, + kOTEthernetDevice = 10, + kOTSLIPDevice = 11, + kOTPPPDevice = 12, + kOTModemDevice = 13, + kOTFastEthernetDevice = 14, + kOTFDDIDevice = 15, + kOTIrDADevice = 16, + kOTATMSNAPDevice = 17, + kOTFibreChannelDevice = 18, + kOTFireWireDevice = 19, + kOTPseudoDevice = 1023, + kOTLastDeviceIndex = 1022 +} + +enum +{ + kOTLastSlotNumber = 255, + kOTLastOtherNumber = 255 +} + +enum +{ + kMaxModuleNameLength = 31, + kMaxModuleNameSize = kMaxModuleNameLength + 1, + kMaxProviderNameLength = kMaxModuleNameLength + 4, + kMaxProviderNameSize = kMaxProviderNameLength + 1, + kMaxSlotIDLength = 7, + kMaxSlotIDSize = kMaxSlotIDLength + 1, + kMaxResourceInfoLength = 31, + kMaxResourceInfoSize = 32, + kMaxPortNameLength = kMaxModuleNameLength + 4, + kMaxPortNameSize = kMaxPortNameLength + 1 +} + +enum +{ + kOTPortIsActive = 0x00000001, + kOTPortIsDisabled = 0x00000002, + kOTPortIsUnavailable = 0x00000004, + kOTPortIsOffline = 0x00000008 +} + +enum +{ + kOTPortIsDLPI = 0x00000001, + kOTPortIsTPI = 0x00000002, + kOTPortCanYield = 0x00000004, + kOTPortCanArbitrate = 0x00000008, + kOTPortIsTransitory = 0x00000010, + kOTPortAutoConnects = 0x00000020, + kOTPortIsSystemRegistered = 0x00004000, + kOTPortIsPrivate = 0x00008000, + kOTPortIsAlias = cast(uint)0x80000000 +} + +enum : uint +{ + kNetbufDataIsOTData = 0xFFFFFFFE +} + +enum : uint +{ + kOTNetbufDataIsOTBufferStar = 0xFFFFFFFD +} + +enum : uint +{ + kOTNetbufIsRawMode = 0xFFFFFFFF +} + +enum +{ + kInitOTForApplicationMask = 1, + kInitOTForExtensionMask = 2 +} + +struct OTAddress +{ + ushort fAddressType; + char* fAddress; +} + + +struct OTScriptInfo +{ + uint fScriptType; + void* fTheScript; + uint fScriptLength; +} + +struct TOption +{ + uint len; + uint level; + uint name; + uint status; + UInt32* value; +} + + +struct t_kpalive +{ + int kp_onoff; + int kp_timeout; +} + + +struct t_linger +{ + int l_onoff; + int l_linger; +} + + +struct TEndpointInfo +{ + int addr; + int options; + int tsdu; + int etsdu; + int connect; + int discon; + uint servtype; + uint flags; +} + + +struct OTPortRecord +{ + uint fRef; + uint fPortFlags; + uint fInfoFlags; + uint fCapabilities; + uint fNumChildPorts; + OTPortRef* fChildPorts; + char* fPortName; + char* fModuleName; + char* fSlotID; + char* fResourceInfo; + char* fReserved; +} + + +struct TNetbuf +{ + uint maxlen; + uint len; + char* buf; +} + + +struct strbuf +{ + int maxlen; + int len; + char* buf; +} + + +struct OTData +{ + void* fNext; + void* fData; + uint fLen; +} + + +struct OTBuffer +{ + void* fLink; + void* fLink2; + OTBuffer* fNext; + char* fData; + uint fLen; + void* fSave; + ubyte fBand; + ubyte fType; + ubyte fPad1; + ubyte fFlags; +} + + +struct OTBufferInfo +{ + OTBuffer* fBuffer; + uint fOffset; + ubyte fPad; +} + + +struct TBind +{ + TNetbuf addr; + uint qlen; +} + + +struct TDiscon +{ + TNetbuf udata; + int reason; + int sequence; +} + + +struct TCall +{ + TNetbuf addr; + TNetbuf opt; + TNetbuf udata; + int sequence; +} + + +struct TUnitData +{ + TNetbuf addr; + TNetbuf opt; + TNetbuf udata; +} + + +struct TUDErr +{ + TNetbuf addr; + TNetbuf opt; + int error; +} + + +struct TOptMgmt +{ + TNetbuf opt; + uint flags; +} + + +struct TRequest +{ + TNetbuf data; + TNetbuf opt; + int sequence; +} + + +struct TReply +{ + TNetbuf data; + TNetbuf opt; + int sequence; +} + + +struct TUnitRequest +{ + TNetbuf addr; + TNetbuf opt; + TNetbuf udata; + int sequence; +} + + +struct TUnitReply +{ + TNetbuf opt; + TNetbuf udata; + int sequence; +} + + +struct TRegisterRequest +{ + TNetbuf name; + TNetbuf addr; + uint flags; +} + + +struct TRegisterReply +{ + TNetbuf addr; + int nameid; +} + + +struct TLookupRequest +{ + TNetbuf name; + TNetbuf addr; + uint maxcnt; + uint timeout; + uint flags; +} + + +struct TLookupReply +{ + TNetbuf names; + uint rspcount; +} + + +struct TLookupBuffer +{ + ushort fAddressLength; + ushort fNameLength; + char* fAddressBuffer; +} + + +struct OTLink +{ + OTLink* fNext; +} + + +struct OTLIFO +{ + OTLink* fHead; +} + + +struct OTList +{ + OTLink* fHead; +} + +extern (C) +{ + OTNotifyUPP NewOTNotifyUPP (OTNotifyProcPtr userRoutine); + void DisposeOTNotifyUPP (OTNotifyUPP userUPP); + void InvokeOTNotifyUPP (void* contextPtr, uint code, int result, void* cookie, OTNotifyUPP userUPP); + OTProcessUPP NewOTProcessUPP (OTProcessProcPtr userRoutine); + void DisposeOTProcessUPP (OTProcessUPP userUPP); + void InvokeOTProcessUPP (void* arg, OTProcessUPP userUPP); + OTListSearchUPP NewOTListSearchUPP (OTListSearchProcPtr userRoutine); + void DisposeOTListSearchUPP (OTListSearchUPP userUPP); + ubyte InvokeOTListSearchUPP (void* ref_, OTLink* linkToCheck, OTListSearchUPP userUPP); +} \ No newline at end of file