comparison 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
comparison
equal deleted inserted replaced
10:27e00625790b 11:07194b026fa4
1 /**
2 * Copyright: Copyright (c) 2009 Jacob Carlborg.
3 * Authors: Jacob Carlborg
4 * Version: Initial created: Jul 22, 2009
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
6 */
7 module dstep.coreservices.osservices.OpenTransport;
8
9 //import dstep.AvailabilityMacros;
10 import dstep.coreservices.carboncore.MacErrors;
11 import dstep.coreservices.carboncore.MacTypes;
12 import dstep.coreservices.carboncore.MixedMode;
13 import dstep.internal.Version;
14 import dstep.objc.bridge.TypeEncoding;
15 //import dstep.stddef;
16
17 struct OTConfiguration;
18 struct OpaqueOTClientContextPtr;
19
20 struct TOptionHeader
21 {
22 uint len;
23 uint level;
24 uint name;
25 uint status;
26 }
27
28 alias ubyte OTUInt8Param;
29 alias ushort OTUInt16Param;
30 alias short OTSInt16Param;
31 alias byte OTSInt8Param;
32 alias ubyte OTBooleanParam;
33 alias ubyte uchar_p;
34 alias ushort ushort_p;
35 alias short short_p;
36 alias byte char_p;
37 alias ubyte boolean_p;
38 alias uint OTByteCount;
39 alias uint OTItemCount;
40 alias int OTInt32;
41 alias uint OTUInt32;
42 alias int int_t;
43 alias uint uint_t;
44 alias uint OTTimeout;
45 alias int OTSequence;
46 alias int OTNameID;
47 alias int OTReason;
48 alias uint OTQLen;
49 alias char* OTClientName;
50 alias int OTCommand;
51 alias void* OTClient;
52 alias uint OTOpenFlags;
53 alias ushort OTUnixErr;
54 alias ushort OTXTIErr;
55 alias int OTResult;
56 alias ushort OTAddressType;
57 alias uint OTStructType;
58 alias uint OTFieldsType;
59 alias uint OTFlags;
60 alias uint OTBand;
61 alias void* ProviderRef;
62 alias void* EndpointRef;
63 alias void* MapperRef;
64 alias uint OTEventCode;
65 alias OTNotifyProcPtr OTNotifyUPP;
66 alias uint OTXTILevel;
67 alias uint OTXTIName;
68 alias uint OTXTIStates;
69 alias OTConfiguration* OTConfigurationRef;
70 alias uint OTServiceType;
71 alias int OTDataSize;
72 alias uint OTPortRef;
73 alias OTPortRef* OTPortRefPtr;
74 alias ubyte OTBusType;
75 alias ushort OTDeviceType;
76 alias ushort OTSlotNumber;
77 alias OpaqueOTClientContextPtr* OTClientContextPtr;
78 alias uint OTInitializationFlags;
79 alias OTProcessProcPtr OTProcessUPP;
80 alias int OTDeferredTaskRef;
81 alias int OTSystemTaskRef;
82 alias UnsignedWide OTTimeStamp;
83 alias OTListSearchProcPtr OTListSearchUPP;
84 alias ubyte OTLock;
85
86 extern (C)
87 {
88 alias ubyte function (void*, OTLink*) OTListSearchProcPtr;
89 alias void function (void*) OTProcessProcPtr;
90 alias void function (void*, uint, int, void*) OTNotifyProcPtr;
91 }
92
93 // This is needed otherwise the enums will fail compiling with gdc
94 version (GNU)
95 {
96 private
97 {
98 const __kOTCFMClass = getOSType!("otan");
99 }
100 }
101
102 enum
103 {
104 kOTCFMClass = getOSType!("otan")
105 }
106
107 enum
108 {
109 kO_ASYNC = 0x01,
110 kO_NDELAY = 0x04,
111 kO_NONBLOCK = 0x04
112 }
113
114 enum
115 {
116 TSUCCESS = 0,
117 TBADADDR = 1,
118 TBADOPT = 2,
119 TACCES = 3,
120 TBADF = 4,
121 TNOADDR = 5,
122 TOUTSTATE = 6,
123 TBADSEQ = 7,
124 TSYSERR = 8,
125 TLOOK = 9,
126 TBADDATA = 10,
127 TBUFOVFLW = 11,
128 TFLOW = 12,
129 TNODATA = 13,
130 TNODIS = 14,
131 TNOUDERR = 15,
132 TBADFLAG = 16,
133 TNOREL = 17,
134 TNOTSUPPORT = 18,
135 TSTATECHNG = 19,
136 TNOSTRUCTYPE = 20,
137 TBADNAME = 21,
138 TBADQLEN = 22,
139 TADDRBUSY = 23,
140 TINDOUT = 24,
141 TPROVMISMATCH = 25,
142 TRESQLEN = 26,
143 TRESADDR = 27,
144 TQFULL = 28,
145 TPROTO = 29,
146 TBADSYNC = 30,
147 TCANCELED = 31,
148 TLASTXTIERROR = 31
149 }
150
151 enum
152 {
153 kOTGenericName = 0
154 }
155
156 enum
157 {
158 T_BIND = 1,
159 T_OPTMGMT = 2,
160 T_CALL = 3,
161 T_DIS = 4,
162 T_UNITDATA = 5,
163 T_UDERROR = 6,
164 T_INFO = 7,
165 T_REPLYDATA = 8,
166 T_REQUESTDATA = 9,
167 T_UNITREQUEST = 10,
168 T_UNITREPLY = 11
169 }
170
171 enum
172 {
173 T_ADDR = 0x01,
174 T_OPT = 0x02,
175 T_UDATA = 0x04,
176 T_ALL = 0xFFFF
177 }
178
179 enum
180 {
181 T_MORE = 0x0001,
182 T_EXPEDITED = 0x0002,
183 T_ACKNOWLEDGED = 0x0004,
184 T_PARTIALDATA = 0x0008,
185 T_NORECEIPT = 0x0010,
186 T_TIMEDOUT = 0x0020
187 }
188
189 enum
190 {
191 T_NEGOTIATE = 0x0004,
192 T_CHECK = 0x0008,
193 T_DEFAULT = 0x0010,
194 T_CURRENT = 0x0080
195 }
196
197 enum
198 {
199 T_SUCCESS = 0x0020,
200 T_FAILURE = 0x0040,
201 T_PARTSUCCESS = 0x0100,
202 T_READONLY = 0x0200,
203 T_NOTSUPPORT = 0x0400
204 }
205
206 enum
207 {
208 T_LISTEN = 0x0001,
209 T_CONNECT = 0x0002,
210 T_DATA = 0x0004,
211 T_EXDATA = 0x0008,
212 T_DISCONNECT = 0x0010,
213 T_ERROR = 0x0020,
214 T_UDERR = 0x0040,
215 T_ORDREL = 0x0080,
216 T_GODATA = 0x0100,
217 T_GOEXDATA = 0x0200,
218 T_REQUEST = 0x0400,
219 T_REPLY = 0x0800,
220 T_PASSCON = 0x1000,
221 T_RESET = 0x2000,
222 kPRIVATEEVENT = 0x10000000,
223 kCOMPLETEEVENT = 0x20000000,
224 T_BINDCOMPLETE = 0x20000001,
225 T_UNBINDCOMPLETE = 0x20000002,
226 T_ACCEPTCOMPLETE = 0x20000003,
227 T_REPLYCOMPLETE = 0x20000004,
228 T_DISCONNECTCOMPLETE = 0x20000005,
229 T_OPTMGMTCOMPLETE = 0x20000006,
230 T_OPENCOMPLETE = 0x20000007,
231 T_GETPROTADDRCOMPLETE = 0x20000008,
232 T_RESOLVEADDRCOMPLETE = 0x20000009,
233 T_GETINFOCOMPLETE = 0x2000000A,
234 T_SYNCCOMPLETE = 0x2000000B,
235 T_MEMORYRELEASED = 0x2000000C,
236 T_REGNAMECOMPLETE = 0x2000000D,
237 T_DELNAMECOMPLETE = 0x2000000E,
238 T_LKUPNAMECOMPLETE = 0x2000000F,
239 T_LKUPNAMERESULT = 0x20000010,
240 kOTSyncIdleEvent = 0x20000011,
241 kSTREAMEVENT = 0x21000000,
242 kOTReservedEvent1 = 0x21000001,
243 kGetmsgEvent = 0x21000002,
244 kStreamReadEvent = 0x21000003,
245 kStreamWriteEvent = 0x21000004,
246 kStreamIoctlEvent = 0x21000005,
247 kOTReservedEvent2 = 0x21000006,
248 kStreamOpenEvent = 0x21000007,
249 kPollEvent = 0x21000008,
250 kOTReservedEvent3 = 0x21000009,
251 kOTReservedEvent4 = 0x2100000A,
252 kOTReservedEvent5 = 0x2100000B,
253 kOTReservedEvent6 = 0x2100000C,
254 kOTReservedEvent7 = 0x2100000D,
255 kOTReservedEvent8 = 0x2100000E,
256 kSIGNALEVENT = 0x22000000,
257 kPROTOCOLEVENT = 0x23000000,
258 kOTProviderIsDisconnected = 0x23000001,
259 kOTProviderIsReconnected = 0x23000002,
260 kOTProviderWillClose = 0x24000001,
261 kOTProviderIsClosed = 0x24000002,
262 kOTPortDisabled = 0x25000001,
263 kOTPortEnabled = 0x25000002,
264 kOTPortOffline = 0x25000003,
265 kOTPortOnline = 0x25000004,
266 kOTClosePortRequest = 0x25000005,
267 kOTYieldPortRequest = 0x25000005,
268 kOTNewPortRegistered = 0x25000006,
269 kOTPortNetworkChange = 0x25000007,
270 kOTConfigurationChanged = 0x26000001,
271 kOTSystemSleep = 0x26000002,
272 kOTSystemShutdown = 0x26000003,
273 kOTSystemAwaken = 0x26000004,
274 kOTSystemIdle = 0x26000005,
275 kOTSystemSleepPrep = 0x26000006,
276 kOTSystemShutdownPrep = 0x26000007,
277 kOTSystemAwakenPrep = 0x26000008,
278 kOTStackIsLoading = 0x27000001,
279 kOTStackWasLoaded = 0x27000002,
280 kOTStackIsUnloading = 0x27000003
281 }
282
283 enum
284 {
285 kOTDisablePortEvent = 0x21000001,
286 kStreamCloseEvent = 0x21000006,
287 kBackgroundStreamEvent = 0x21000009,
288 kIoctlRecvFdEvent = 0x2100000A,
289 kOTTryShutdownEvent = 0x2100000B,
290 kOTScheduleTerminationEvent = 0x2100000C,
291 kOTEnablePortEvent = 0x2100000D,
292 kOTNewPortRegisteredEvent = 0x2100000E,
293 kOTPortOfflineEvent = 0x2100000F,
294 kOTPortOnlineEvent = 0x21000010,
295 kOTPortNetworkChangeEvent = 0x21000011
296 }
297
298 enum
299 {
300 kSIGHUP = 1,
301 kSIGURG = 16,
302 kSIGPOLL = 30
303 }
304
305 enum
306 {
307 XTI_GENERIC = 0xFFFF
308 }
309
310 enum
311 {
312 XTI_DEBUG = 0x0001,
313 XTI_LINGER = 0x0080,
314 XTI_RCVBUF = 0x1002,
315 XTI_RCVLOWAT = 0x1004,
316 XTI_SNDBUF = 0x1001,
317 XTI_SNDLOWAT = 0x1003,
318 XTI_PROTOTYPE = 0x1005,
319 OPT_CHECKSUM = 0x0600,
320 OPT_RETRYCNT = 0x0601,
321 OPT_INTERVAL = 0x0602,
322 OPT_ENABLEEOM = 0x0603,
323 OPT_SELFSEND = 0x0604,
324 OPT_SERVERSTATUS = 0x0605,
325 OPT_ALERTENABLE = 0x0606,
326 OPT_KEEPALIVE = 0x0008
327 }
328
329 enum
330 {
331 MIOC_STREAMIO = 'A',
332 MIOC_TMOD = 'a',
333 MIOC_STRLOG = 'b',
334 MIOC_ND = 'c',
335 MIOC_ECHO = 'd',
336 MIOC_TLI = 'e',
337 MIOC_RESERVEDf = 'f',
338 MIOC_SAD = 'g',
339 MIOC_ARP = 'h',
340 MIOC_HAVOC = 'H',
341 MIOC_RESERVEDi = 'i',
342 MIOC_SIOC = 'j',
343 MIOC_TCP = 'k',
344 MIOC_DLPI = 'l',
345 MIOC_SOCKETS = 'm',
346 MIOC_IPX = 'o',
347 MIOC_OT = 'O',
348 MIOC_ATALK = 'T',
349 MIOC_SRL = 'U',
350 MIOC_RESERVEDp = 'p',
351 MIOC_RESERVEDr = 'r',
352 MIOC_RESERVEDs = 's',
353 MIOC_CFIG = 'z'
354 }
355
356 enum
357 {
358 I_OTGetMiscellaneousEvents = ((MIOC_OT << 8) | 1),
359 I_OTSetFramingType = ((MIOC_OT << 8) | 2),
360 kOTGetFramingValue = cast(uint)0xFFFFFFFF,
361 I_OTSetRawMode = ((MIOC_OT << 8) | 3),
362 kOTSetRecvMode = 0x01,
363 kOTSendErrorPacket = 0x02,
364 I_OTConnect = ((MIOC_OT << 8) | 4),
365 I_OTDisconnect = ((MIOC_OT << 8) | 5),
366 I_OTScript = ((MIOC_OT << 8) | 6)
367 }
368
369 enum
370 {
371 T_UNINIT = 0,
372 T_UNBND = 1,
373 T_IDLE = 2,
374 T_OUTCON = 3,
375 T_INCON = 4,
376 T_DATAXFER = 5,
377 T_OUTREL = 6,
378 T_INREL = 7
379 }
380
381 static if (D_LP64)
382 {
383 enum : ulong
384 {
385 T_YES = 1,
386 T_NO = 0,
387 T_UNUSED = -1,
388 kT_NULL = 0,
389 T_ABSREQ = 0x8000
390 }
391 }
392
393 else
394 {
395 enum : uint
396 {
397 T_YES = 1,
398 T_NO = 0,
399 T_UNUSED = -1,
400 kT_NULL = 0,
401 T_ABSREQ = 0x8000
402 }
403 }
404
405 enum
406 {
407 kT_UNSPEC = cast(uint)0xFFFFFFFD,
408 T_ALLOPT = 0
409 }
410
411 enum
412 {
413 kOTOptionHeaderSize = TOptionHeader.sizeof,
414 kOTBooleanOptionDataSize = uint.sizeof,
415 kOTBooleanOptionSize = kOTOptionHeaderSize + kOTBooleanOptionDataSize,
416 kOTOneByteOptionSize = kOTOptionHeaderSize + 1,
417 kOTTwoByteOptionSize = kOTOptionHeaderSize + 2,
418 kOTFourByteOptionSize = kOTOptionHeaderSize + uint.sizeof
419 }
420
421 enum
422 {
423 T_COTS = 1,
424 T_COTS_ORD = 2,
425 T_CLTS = 3,
426 T_TRANS = 5,
427 T_TRANS_ORD = 6,
428 T_TRANS_CLTS = 7
429 }
430
431 enum
432 {
433 T_SENDZERO = 0x0001,
434 T_XPG4_1 = 0x0002,
435 T_CAN_SUPPORT_MDATA = 0x10000000,
436 T_CAN_RESOLVE_ADDR = 0x40000000,
437 T_CAN_SUPPLY_MIB = 0x20000000
438 }
439
440 enum
441 {
442 T_INFINITE = -1,
443 T_INVALID = -2
444 }
445
446 enum
447 {
448 kOTInvalidPortRef = 0
449 }
450
451 enum
452 {
453 kOTUnknownBusPort = 0,
454 kOTMotherboardBus = 1,
455 kOTNuBus = 2,
456 kOTPCIBus = 3,
457 kOTGeoPort = 4,
458 kOTPCCardBus = 5,
459 kOTFireWireBus = 6,
460 kOTLastBusIndex = 15
461 }
462
463 enum
464 {
465 kOTNoDeviceType = 0,
466 kOTADEVDevice = 1,
467 kOTMDEVDevice = 2,
468 kOTLocalTalkDevice = 3,
469 kOTIRTalkDevice = 4,
470 kOTTokenRingDevice = 5,
471 kOTISDNDevice = 6,
472 kOTATMDevice = 7,
473 kOTSMDSDevice = 8,
474 kOTSerialDevice = 9,
475 kOTEthernetDevice = 10,
476 kOTSLIPDevice = 11,
477 kOTPPPDevice = 12,
478 kOTModemDevice = 13,
479 kOTFastEthernetDevice = 14,
480 kOTFDDIDevice = 15,
481 kOTIrDADevice = 16,
482 kOTATMSNAPDevice = 17,
483 kOTFibreChannelDevice = 18,
484 kOTFireWireDevice = 19,
485 kOTPseudoDevice = 1023,
486 kOTLastDeviceIndex = 1022
487 }
488
489 enum
490 {
491 kOTLastSlotNumber = 255,
492 kOTLastOtherNumber = 255
493 }
494
495 enum
496 {
497 kMaxModuleNameLength = 31,
498 kMaxModuleNameSize = kMaxModuleNameLength + 1,
499 kMaxProviderNameLength = kMaxModuleNameLength + 4,
500 kMaxProviderNameSize = kMaxProviderNameLength + 1,
501 kMaxSlotIDLength = 7,
502 kMaxSlotIDSize = kMaxSlotIDLength + 1,
503 kMaxResourceInfoLength = 31,
504 kMaxResourceInfoSize = 32,
505 kMaxPortNameLength = kMaxModuleNameLength + 4,
506 kMaxPortNameSize = kMaxPortNameLength + 1
507 }
508
509 enum
510 {
511 kOTPortIsActive = 0x00000001,
512 kOTPortIsDisabled = 0x00000002,
513 kOTPortIsUnavailable = 0x00000004,
514 kOTPortIsOffline = 0x00000008
515 }
516
517 enum
518 {
519 kOTPortIsDLPI = 0x00000001,
520 kOTPortIsTPI = 0x00000002,
521 kOTPortCanYield = 0x00000004,
522 kOTPortCanArbitrate = 0x00000008,
523 kOTPortIsTransitory = 0x00000010,
524 kOTPortAutoConnects = 0x00000020,
525 kOTPortIsSystemRegistered = 0x00004000,
526 kOTPortIsPrivate = 0x00008000,
527 kOTPortIsAlias = cast(uint)0x80000000
528 }
529
530 enum : uint
531 {
532 kNetbufDataIsOTData = 0xFFFFFFFE
533 }
534
535 enum : uint
536 {
537 kOTNetbufDataIsOTBufferStar = 0xFFFFFFFD
538 }
539
540 enum : uint
541 {
542 kOTNetbufIsRawMode = 0xFFFFFFFF
543 }
544
545 enum
546 {
547 kInitOTForApplicationMask = 1,
548 kInitOTForExtensionMask = 2
549 }
550
551 struct OTAddress
552 {
553 ushort fAddressType;
554 char* fAddress;
555 }
556
557
558 struct OTScriptInfo
559 {
560 uint fScriptType;
561 void* fTheScript;
562 uint fScriptLength;
563 }
564
565 struct TOption
566 {
567 uint len;
568 uint level;
569 uint name;
570 uint status;
571 UInt32* value;
572 }
573
574
575 struct t_kpalive
576 {
577 int kp_onoff;
578 int kp_timeout;
579 }
580
581
582 struct t_linger
583 {
584 int l_onoff;
585 int l_linger;
586 }
587
588
589 struct TEndpointInfo
590 {
591 int addr;
592 int options;
593 int tsdu;
594 int etsdu;
595 int connect;
596 int discon;
597 uint servtype;
598 uint flags;
599 }
600
601
602 struct OTPortRecord
603 {
604 uint fRef;
605 uint fPortFlags;
606 uint fInfoFlags;
607 uint fCapabilities;
608 uint fNumChildPorts;
609 OTPortRef* fChildPorts;
610 char* fPortName;
611 char* fModuleName;
612 char* fSlotID;
613 char* fResourceInfo;
614 char* fReserved;
615 }
616
617
618 struct TNetbuf
619 {
620 uint maxlen;
621 uint len;
622 char* buf;
623 }
624
625
626 struct strbuf
627 {
628 int maxlen;
629 int len;
630 char* buf;
631 }
632
633
634 struct OTData
635 {
636 void* fNext;
637 void* fData;
638 uint fLen;
639 }
640
641
642 struct OTBuffer
643 {
644 void* fLink;
645 void* fLink2;
646 OTBuffer* fNext;
647 char* fData;
648 uint fLen;
649 void* fSave;
650 ubyte fBand;
651 ubyte fType;
652 ubyte fPad1;
653 ubyte fFlags;
654 }
655
656
657 struct OTBufferInfo
658 {
659 OTBuffer* fBuffer;
660 uint fOffset;
661 ubyte fPad;
662 }
663
664
665 struct TBind
666 {
667 TNetbuf addr;
668 uint qlen;
669 }
670
671
672 struct TDiscon
673 {
674 TNetbuf udata;
675 int reason;
676 int sequence;
677 }
678
679
680 struct TCall
681 {
682 TNetbuf addr;
683 TNetbuf opt;
684 TNetbuf udata;
685 int sequence;
686 }
687
688
689 struct TUnitData
690 {
691 TNetbuf addr;
692 TNetbuf opt;
693 TNetbuf udata;
694 }
695
696
697 struct TUDErr
698 {
699 TNetbuf addr;
700 TNetbuf opt;
701 int error;
702 }
703
704
705 struct TOptMgmt
706 {
707 TNetbuf opt;
708 uint flags;
709 }
710
711
712 struct TRequest
713 {
714 TNetbuf data;
715 TNetbuf opt;
716 int sequence;
717 }
718
719
720 struct TReply
721 {
722 TNetbuf data;
723 TNetbuf opt;
724 int sequence;
725 }
726
727
728 struct TUnitRequest
729 {
730 TNetbuf addr;
731 TNetbuf opt;
732 TNetbuf udata;
733 int sequence;
734 }
735
736
737 struct TUnitReply
738 {
739 TNetbuf opt;
740 TNetbuf udata;
741 int sequence;
742 }
743
744
745 struct TRegisterRequest
746 {
747 TNetbuf name;
748 TNetbuf addr;
749 uint flags;
750 }
751
752
753 struct TRegisterReply
754 {
755 TNetbuf addr;
756 int nameid;
757 }
758
759
760 struct TLookupRequest
761 {
762 TNetbuf name;
763 TNetbuf addr;
764 uint maxcnt;
765 uint timeout;
766 uint flags;
767 }
768
769
770 struct TLookupReply
771 {
772 TNetbuf names;
773 uint rspcount;
774 }
775
776
777 struct TLookupBuffer
778 {
779 ushort fAddressLength;
780 ushort fNameLength;
781 char* fAddressBuffer;
782 }
783
784
785 struct OTLink
786 {
787 OTLink* fNext;
788 }
789
790
791 struct OTLIFO
792 {
793 OTLink* fHead;
794 }
795
796
797 struct OTList
798 {
799 OTLink* fHead;
800 }
801
802 extern (C)
803 {
804 OTNotifyUPP NewOTNotifyUPP (OTNotifyProcPtr userRoutine);
805 void DisposeOTNotifyUPP (OTNotifyUPP userUPP);
806 void InvokeOTNotifyUPP (void* contextPtr, uint code, int result, void* cookie, OTNotifyUPP userUPP);
807 OTProcessUPP NewOTProcessUPP (OTProcessProcPtr userRoutine);
808 void DisposeOTProcessUPP (OTProcessUPP userUPP);
809 void InvokeOTProcessUPP (void* arg, OTProcessUPP userUPP);
810 OTListSearchUPP NewOTListSearchUPP (OTListSearchProcPtr userRoutine);
811 void DisposeOTListSearchUPP (OTListSearchUPP userUPP);
812 ubyte InvokeOTListSearchUPP (void* ref_, OTLink* linkToCheck, OTListSearchUPP userUPP);
813 }