Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4831 lines
142 KiB

  1. /*
  2. File: OpenTransport.h
  3. Contains: Open Transport client interface file.
  4. Version: QuickTime 7.3
  5. Copyright: (c) 2007 (c) 1985-2001 by Apple Computer, Inc., all rights reserved
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://developer.apple.com/bugreporter/
  9. */
  10. #ifndef __OPENTRANSPORT__
  11. #define __OPENTRANSPORT__
  12. /*
  13. The following table shows how to map from the old (pre-Universal
  14. Interfaces) header file name to the equivalent Universal Interfaces
  15. header file name.
  16. Old Header New Header
  17. ---------- ----------
  18. cred.h OpenTransportProtocol.h
  19. dlpi.h OpenTransportProtocol.h
  20. miioccom.h OpenTransportProtocol.h
  21. mistream.h OpenTransportProtocol.h/OpenTransportKernel.h
  22. modnames.h OpenTransportProtocol.h
  23. OpenTptAppleTalk.h OpenTransportProviders.h
  24. OpenTptClient.h OpenTransportProtocol.h
  25. OpenTptCommon.h OpenTransportProtocol.h
  26. OpenTptConfig.h OpenTransportProtocol.h
  27. OpenTptDevLinks.h OpenTransportProviders.h
  28. OpenTptInternet.h OpenTransportProviders.h
  29. OpenTptISDN.h OpenTransportProviders.h
  30. OpenTptLinks.h OpenTransportProviders.h
  31. OpenTptModule.h OpenTransportKernel.h
  32. OpenTptPCISupport.h OpenTransportKernel.h
  33. OpenTptSerial.h OpenTransportProviders.h
  34. OpenTptXTI.h OpenTransportUNIX.r
  35. OpenTransport.h OpenTransport.h
  36. OpenTransport.r OpenTransport.r
  37. OTConfig.r OpenTransportProtocol.r
  38. OTDebug.h OpenTransport.h
  39. OTSharedLibs.h OpenTransportProviders.h
  40. strlog.h OpenTransportProtocol.h/OpenTransportKernel.h
  41. stropts.h OpenTransportProtocol.h/OpenTransportUNIX.h
  42. strstat.h OpenTransportProtocol.h
  43. tihdr.h OpenTransportProtocol.h
  44. */
  45. #ifndef __MACTYPES__
  46. #include <MacTypes.h>
  47. #endif
  48. #ifndef __MIXEDMODE__
  49. #include <MixedMode.h>
  50. #endif
  51. #ifndef __MACERRORS__
  52. #include <MacErrors.h>
  53. #endif
  54. #ifdef __cplusplus
  55. #include <stddef.h>
  56. #endif
  57. #if PRAGMA_ONCE
  58. #pragma once
  59. #endif
  60. #ifdef __cplusplus
  61. extern "C" {
  62. #endif
  63. #if PRAGMA_IMPORT
  64. #pragma import on
  65. #endif
  66. #if PRAGMA_STRUCT_ALIGN
  67. #pragma options align=mac68k
  68. #elif PRAGMA_STRUCT_PACKPUSH
  69. #pragma pack(push, 2)
  70. #elif PRAGMA_STRUCT_PACK
  71. #pragma pack(2)
  72. #endif
  73. #if defined(__MWERKS__) && TARGET_CPU_68K
  74. #pragma push
  75. #pragma pointers_in_D0
  76. #endif
  77. /* ***** Setup Default Compiler Variables ******/
  78. /*
  79. OTKERNEL is used to indicate whether the code is being built
  80. for the kernel environment. It defaults to 0. If you include
  81. "OpenTransportKernel.h" before including this file,
  82. it will be 1 and you will only be able to see stuff available
  83. to kernel code.
  84. */
  85. #ifndef OTKERNEL
  86. #define OTKERNEL 0
  87. #endif /* !defined(OTKERNEL) */
  88. /*
  89. OTUNIXERRORS determines whether this file defines a bunch of
  90. common UNIX error codes, like EPERM. Typically, client code does
  91. not want to do this because of the possibility of a clash with
  92. other code modules, like the standard C libraries, that also
  93. defines these routines. However, client code can turn it on to
  94. get these definitions. This might be done by protocol stack
  95. infrastructure, or some other low-level code.
  96. "OpenTransportKernel.i" sets this flag before include
  97. "OpenTransport.h" because kernel modules typically need these
  98. error codes. Note that kernel modules shouldn't be including
  99. standard C libraries, so this is rarely a problem.
  100. In general, the clash between OT and standard C definitions
  101. of these error codes is rarely a problem becasue both OT
  102. and the C libraries define them to have the same value. But
  103. I'm sure this check is useful to some people.
  104. */
  105. #ifndef OTUNIXERRORS
  106. #define OTUNIXERRORS 0
  107. #endif /* !defined(OTUNIXERRORS) */
  108. /*
  109. OTDEBUG is used to control the behaviour of the OT debugging
  110. macros. If you set it to non-zero, the macros will generate code
  111. that drops you into the debugger. If you set it to 0, or leave it
  112. undefined, the macros are compiled out.
  113. Setting up this compiler variable is a little tricky because previous
  114. versions of the OT interfaces used a different variable, qDebug.
  115. We replaced qDebug with OTDEBUG because qDebug does not fit into
  116. the OT namespace. But I didn't want to break a lot of currently
  117. building code. The following tricky compiler variable footwork
  118. avoids this.
  119. There are four outcomes when this code is compiled, depending on
  120. whether qDebug and OTDEBUG are defined beforehand. The following
  121. table shows the outcome in each case.
  122. qDebug OTDEBUG Outcome Explanation
  123. ------ ------- ------- -----------
  124. defined defined OTDEBUG wins Mixed legacy and new code, we believe the new code.
  125. defined undefined qDebug wins Legacy code.
  126. undefined defined OTDEBUG wins New code.
  127. undefined undefined no debugging No debugging.
  128. */
  129. #ifdef qDebug
  130. #ifndef OTDEBUG
  131. #define OTDebug qDebug
  132. #endif /* !defined(OTDEBUG) */
  133. #endif /* defined(qDebug) */
  134. #ifndef OTDEBUG
  135. #define OTDEBUG 0
  136. #endif /* !defined(OTDEBUG) */
  137. /* Carbon Applications have some restrictions on using OT*/
  138. #ifndef OTCARBONAPPLICATION
  139. #define OTCARBONAPPLICATION 0
  140. #endif /* !defined(OTCARBONAPPLICATION) */
  141. /*
  142. ***** Normalise 68K Calling C Conventions *****
  143. Define special types that handle the difference in parameter passing
  144. between different Mac OS C compilers when generating 68K code. OT
  145. exports C calling conventions routines, and various C compilers use
  146. various different conventions. Differences in the placement of the result
  147. are covered above, where we output pragma pointers_in_D0. The other big
  148. difference is how the compilers pass integer parameters less than 32 bits.
  149. The MPW compiler always extends these to 32 bits; other compilers simply
  150. push a value of the appropriate size. We overcome this difference by
  151. defining special OTFooParam types, which are only used when passing
  152. sub 32 bit values to routines. They are always defined to a 32 bit
  153. size, which makes all the compilers do the same thing.
  154. One weird consequence of this is that in more strict type checking
  155. languages (eg Pascal) OTBooleanParam is not compatible with Boolean.
  156. Sorry.
  157. */
  158. #if TARGET_CPU_68K
  159. typedef UInt32 OTUInt8Param;
  160. typedef UInt32 OTUInt16Param;
  161. typedef SInt32 OTSInt16Param;
  162. typedef SInt32 OTSInt8Param;
  163. typedef SInt32 OTBooleanParam;
  164. #else
  165. typedef UInt8 OTUInt8Param;
  166. typedef UInt16 OTUInt16Param;
  167. typedef SInt16 OTSInt16Param;
  168. typedef SInt8 OTSInt8Param;
  169. typedef Boolean OTBooleanParam;
  170. #endif /* TARGET_CPU_68K */
  171. #if defined(__MWERKS__) || defined(THINK_C) || defined(SYMANTEC_CPLUS) || defined(SYMANTEC_C) || defined (__xlc) || defined (__xlC) || defined (__xlC__)
  172. typedef ByteCount OTByteCount;
  173. typedef ItemCount OTItemCount;
  174. typedef SInt32 OTInt32;
  175. typedef UInt32 OTUInt32;
  176. #else
  177. typedef unsigned int OTByteCount;
  178. typedef unsigned int OTItemCount;
  179. typedef int OTInt32;
  180. typedef unsigned int OTUInt32;
  181. #endif
  182. /* ***** C++ Support ******/
  183. /*
  184. Setup _MDECL to be _cdecl when compiling C++ code with
  185. compilers that support it, or nothing otherwise.
  186. */
  187. #define _MDECL
  188. #if defined(__SC__) || defined(THINK_CPLUS) || defined(__MRC__)
  189. #ifdef __cplusplus
  190. #undef _MDECL
  191. #define _MDECL _cdecl
  192. #endif
  193. #endif
  194. /* ***** Shared Library Prefixes ******/
  195. #define kOTLibraryVersion "1.1"
  196. #define kOTLibraryPrefix "OTLib$"
  197. #define kOTModulePrefix "OTModl$"
  198. #define kOTClientPrefix "OTClnt$"
  199. #define kOTKernelPrefix "OTKrnl$"
  200. enum {
  201. kOTCFMClass = FOUR_CHAR_CODE('otan')
  202. };
  203. /* ***** Miscellaneous Type Definitions ******/
  204. /* A millisecond timeout value*/
  205. typedef UInt32 OTTimeout;
  206. /* An ID number in connections/transactions */
  207. typedef SInt32 OTSequence;
  208. /* An ID number for registered names */
  209. typedef SInt32 OTNameID;
  210. /*
  211. A protocol-specific reason code for failure.
  212. Usually a Unix-style positive error code.
  213. */
  214. typedef SInt32 OTReason;
  215. /* Number of outstanding connection requests at a time.*/
  216. typedef UInt32 OTQLen;
  217. /* Will become internationalizeable shortly (yeah, right).*/
  218. typedef UInt8 * OTClientName;
  219. /* The command code in STREAMS messages.*/
  220. typedef SInt32 OTCommand;
  221. /* value describing a client*/
  222. typedef struct OpaqueOTClient* OTClient;
  223. /*
  224. OT now defines its own version of the standard C "offsetof"
  225. macro so as to avoid including <stddef.h>.
  226. */
  227. #define OTOffsetOf(structure,field) ((ByteCount)&((structure *) 0)->field)
  228. /* ***** Debugging Macros ******/
  229. #define kOTFatalErr "FB "
  230. #define kOTNonfatalErr "NB "
  231. #define kOTExtFatalErr "FX "
  232. #define kOTExtNonfatalErr "NX "
  233. #define kOTUserFatalErr "UF "
  234. #define kOTUserErr "UE "
  235. #define kOTUserNonfatalErr "UE "
  236. #define kOTInfoErr "IE "
  237. #define kOTInfoBreak "IN "
  238. #if CALL_NOT_IN_CARBON
  239. /*
  240. * OTDebugStr()
  241. *
  242. * Availability:
  243. * Non-Carbon CFM: not available
  244. * CarbonLib: not available
  245. * Mac OS X: not available
  246. */
  247. EXTERN_API( void )
  248. OTDebugStr(const char * str);
  249. #if qDebug > 0
  250. #define OTDebugBreak(str) OTDebugStr(str)
  251. #define OTDebugTest(val, str) { if ( val ) OTDebugStr(str); }
  252. #define OTAssert(name, cond) ((cond) ? ((void) 0) : (OTDebugStr( __FILE__ ": " #name ": " #cond )))
  253. #else
  254. #define OTDebugBreak(str)
  255. #define OTDebugTest(val, str)
  256. #define OTAssert(name, cond)
  257. #endif /* qDebug > 0 */
  258. #if qDebug > 1 || qDebug2 > 1
  259. #define OTDebugBreak2(str) OTDebugStr(str)
  260. #define OTDebugTest2(val, str) { if ( val) OTDebugStr(str); }
  261. #else
  262. #define OTDebugBreak2(str)
  263. #define OTDebugTest2(val, str)
  264. #endif /* qDebug > 1 || qDebug2 > 1 */
  265. #endif /* CALL_NOT_IN_CARBON */
  266. /*
  267. ***** Flags Used When Opening Providers *****
  268. Important
  269. OT does not currently support any of these flags. You should
  270. always pass 0 to a parameter of type OTOpenFlags. If you need
  271. to modify the mode of operation of a provider, use OTSetBlocking,
  272. OTSetSynchronous, etc.
  273. */
  274. typedef UInt32 OTOpenFlags;
  275. enum {
  276. kO_ASYNC = 0x01,
  277. kO_NDELAY = 0x04,
  278. kO_NONBLOCK = 0x04
  279. };
  280. #if CALL_NOT_IN_CARBON
  281. /*
  282. BSD defines O_ASYNC, O_NDELAY and O_NONBLOCK in fcntl.h
  283. Use kO_ASYNC, kO_NDELAY and kO_NONBLOCK in the unlikely event you need the OT value in Carbon
  284. */
  285. enum {
  286. O_ASYNC = kO_ASYNC,
  287. O_NDELAY = kO_NDELAY,
  288. O_NONBLOCK = kO_NONBLOCK
  289. };
  290. #endif /* CALL_NOT_IN_CARBON */
  291. /* ***** UNIX-Style Error Codes ******/
  292. typedef UInt16 OTUnixErr;
  293. /*
  294. These definitions are only compiled if you're building kernel code
  295. or you explicit request them by setting OTUNIXERRORS. See the
  296. description of these compiler variables, given above.
  297. */
  298. #if OTKERNEL || OTUNIXERRORS
  299. /*
  300. There may be some error code confusions with other compiler vendor header
  301. files - However, these match both MPW and AIX definitions.
  302. */
  303. /*
  304. First we undefine the #defined ones we know about so that we can put them
  305. in an enum. Of course, this is only going to work in C, but hopefully
  306. other languages won't have these symbols overloaded.
  307. */
  308. #undef EPERM
  309. #undef ENOENT
  310. #undef ENORSRC
  311. #undef EINTR
  312. #undef EIO
  313. #undef ENXIO
  314. #undef E2BIG
  315. #undef EBADF
  316. #undef EAGAIN
  317. #undef ENOMEM
  318. #undef EACCES
  319. #undef EFAULT
  320. #undef EBUSY
  321. #undef EEXIST
  322. #undef ENODEV
  323. #undef EINVAL
  324. #undef ENOTTY
  325. #undef ERANGE
  326. #undef ESRCH
  327. #undef EPIPE
  328. enum {
  329. EPERM = 1, /* Permission denied */
  330. ENOENT = 2, /* No such file or directory */
  331. ENORSRC = 3, /* No such resource */
  332. EINTR = 4, /* Interrupted system service */
  333. EIO = 5, /* I/O error */
  334. ENXIO = 6, /* No such device or address */
  335. EBADF = 9, /* Bad file number */
  336. EAGAIN = 11, /* Try operation again later */
  337. ENOMEM = 12, /* Not enough space */
  338. EACCES = 13, /* Permission denied */
  339. EFAULT = 14, /* Bad address */
  340. EBUSY = 16, /* Device or resource busy */
  341. EEXIST = 17, /* File exists */
  342. ENODEV = 19, /* No such device */
  343. EINVAL = 22, /* Invalid argument */
  344. ENOTTY = 25, /* Not a character device */
  345. EPIPE = 32, /* Broken pipe */
  346. ERANGE = 34, /* Math result not representable */
  347. EDEADLK = 35, /* Call would block so was aborted */
  348. EWOULDBLOCK = 35, /* Or a deadlock would occur */
  349. EALREADY = 37,
  350. ENOTSOCK = 38, /* Socket operation on non-socket */
  351. EDESTADDRREQ = 39, /* Destination address required */
  352. EMSGSIZE = 40, /* Message too long */
  353. EPROTOTYPE = 41, /* Protocol wrong type for socket */
  354. ENOPROTOOPT = 42, /* Protocol not available */
  355. EPROTONOSUPPORT = 43, /* Protocol not supported */
  356. ESOCKTNOSUPPORT = 44, /* Socket type not supported */
  357. EOPNOTSUPP = 45, /* Operation not supported on socket */
  358. EADDRINUSE = 48, /* Address already in use */
  359. EADDRNOTAVAIL = 49, /* Can't assign requested address */
  360. ENETDOWN = 50, /* Network is down */
  361. ENETUNREACH = 51, /* Network is unreachable */
  362. ENETRESET = 52, /* Network dropped connection on reset */
  363. ECONNABORTED = 53, /* Software caused connection abort */
  364. ECONNRESET = 54, /* Connection reset by peer */
  365. ENOBUFS = 55, /* No buffer space available */
  366. EISCONN = 56, /* Socket is already connected */
  367. ENOTCONN = 57, /* Socket is not connected */
  368. ESHUTDOWN = 58, /* Can't send after socket shutdown */
  369. ETOOMANYREFS = 59, /* Too many references: can't splice */
  370. ETIMEDOUT = 60, /* Connection timed out */
  371. ECONNREFUSED = 61, /* Connection refused */
  372. EHOSTDOWN = 64, /* Host is down */
  373. EHOSTUNREACH = 65, /* No route to host */
  374. EPROTO = 70, /* STREAMS protocol error */
  375. ETIME = 71,
  376. ENOSR = 72,
  377. EBADMSG = 73,
  378. ECANCEL = 74,
  379. ENOSTR = 75,
  380. ENODATA = 76,
  381. EINPROGRESS = 77,
  382. ESRCH = 78,
  383. ENOMSG = 79,
  384. ELASTERRNO = 79
  385. };
  386. #endif /* OTKERNEL || OTUNIXERRORS */
  387. /* ***** Open Transport/XTI Error codes ******/
  388. typedef UInt16 OTXTIErr;
  389. enum {
  390. TSUCCESS = 0, /* No Error occurred */
  391. TBADADDR = 1, /* A Bad address was specified */
  392. TBADOPT = 2, /* A Bad option was specified */
  393. TACCES = 3, /* Missing access permission */
  394. TBADF = 4, /* Bad provider reference */
  395. TNOADDR = 5, /* No address was specified */
  396. TOUTSTATE = 6, /* Call issued in wrong state */
  397. TBADSEQ = 7, /* Sequence specified does not exist */
  398. TSYSERR = 8, /* A system error occurred */
  399. TLOOK = 9, /* An event occurred - call Look() */
  400. TBADDATA = 10, /* An illegal amount of data was specified */
  401. TBUFOVFLW = 11, /* Passed buffer not big enough */
  402. TFLOW = 12, /* Provider is flow-controlled */
  403. TNODATA = 13, /* No data available for reading */
  404. TNODIS = 14, /* No disconnect indication available */
  405. TNOUDERR = 15, /* No Unit Data Error indication available */
  406. TBADFLAG = 16, /* A Bad flag value was supplied */
  407. TNOREL = 17, /* No orderly release indication available */
  408. TNOTSUPPORT = 18, /* Command is not supported */
  409. TSTATECHNG = 19, /* State is changing - try again later */
  410. TNOSTRUCTYPE = 20, /* Bad structure type requested for OTAlloc */
  411. TBADNAME = 21, /* A bad endpoint name was supplied */
  412. TBADQLEN = 22, /* A Bind to an in-use address with qlen > 0*/
  413. TADDRBUSY = 23, /* Address requested is already in use */
  414. TINDOUT = 24, /* Accept failed because of pending listen */
  415. TPROVMISMATCH = 25, /* Tried to accept on incompatible endpoint */
  416. TRESQLEN = 26,
  417. TRESADDR = 27,
  418. TQFULL = 28,
  419. TPROTO = 29, /* An unspecified provider error occurred */
  420. TBADSYNC = 30, /* A synchronous call at interrupt time */
  421. TCANCELED = 31, /* The command was cancelled */
  422. TLASTXTIERROR = 31
  423. };
  424. /*
  425. ***** Mac OS Error Codes *****
  426. Most OT client routines return an OSStatus error code, a 32 bit type
  427. defined in "MacTypes.h". The OT-unique error code values are
  428. defined below. Many of these are generated by remapping XTI error
  429. codes (Txxxx) and UNIX error codes (Exxxx) to a reserved range
  430. in the OSStatus space.
  431. Some routines return an OTResult type, indicating
  432. that the routine might fail with a negative error, succeed with noErr,
  433. or possible return a positive value indicating some status.
  434. */
  435. typedef SInt32 OTResult;
  436. /*
  437. * These map the Open Transport/XTI errors (the Txxxx error codes), and the
  438. * StdCLib Exxxx error codes into unique spaces in the Mac OS OSStatus space.
  439. */
  440. #define XTI2OSStatus(x) (-3149 - (x))
  441. #define E2OSStatus(x) (-3199 - (x))
  442. #define OSStatus2XTI(x) ((OTXTIErr)(-3149 - (x)))
  443. #define OSStatus2E(x) ((OTUnixErr)(-3199 - (x)))
  444. #define IsXTIError(x) ((x) < -3149 && (x) >= (-3149 - TLASTXTIERROR))
  445. #define IsEError(x) ((x) < -3199 && (x) >= (-3199 - ELASTERRNO))
  446. /* ***** OTAddress ******/
  447. /*
  448. OTAddress type defines the standard header for all OT address formats.
  449. It consists of one 16 bit integer, which defines the address format
  450. used, followed by an arbitrary number of bytes which are protocol-specific.
  451. Conceptually, all OT address formats are subtypes of this type,
  452. extended with fields that are specific to the protocol. For example,
  453. OTInetAddress starts with the OTAddressType field and then continues
  454. to include a host IP address and a port number.
  455. */
  456. enum {
  457. kOTGenericName = 0 /* Protocol specific data is just a string, interpreted in a protocol-specific fashion.*/
  458. };
  459. typedef UInt16 OTAddressType;
  460. struct OTAddress {
  461. OTAddressType fAddressType; /* The address format of this address...*/
  462. UInt8 fAddress[1]; /* ... followed by protocol specific address information.*/
  463. };
  464. typedef struct OTAddress OTAddress;
  465. /*
  466. ***** OTAlloc Constants *****
  467. Note:
  468. In general, Apple recommends that you avoid the OTAlloc call because
  469. using it extensively causes your program to allocate and deallocate
  470. many memory blocks, with each extra memory allocation costing time.
  471. */
  472. /*
  473. OTStructType defines the structure type to be allocated using the OTAlloc
  474. call.
  475. */
  476. enum {
  477. T_BIND = 1,
  478. T_OPTMGMT = 2,
  479. T_CALL = 3,
  480. T_DIS = 4,
  481. T_UNITDATA = 5,
  482. T_UDERROR = 6,
  483. T_INFO = 7,
  484. T_REPLYDATA = 8,
  485. T_REQUESTDATA = 9,
  486. T_UNITREQUEST = 10,
  487. T_UNITREPLY = 11
  488. };
  489. typedef UInt32 OTStructType;
  490. /*
  491. These values are used in the "fields" parameter of the OTAlloc call
  492. to define which fields of the structure should be allocated.
  493. */
  494. enum {
  495. T_ADDR = 0x01,
  496. T_OPT = 0x02,
  497. T_UDATA = 0x04,
  498. T_ALL = 0xFFFF
  499. };
  500. typedef UInt32 OTFieldsType;
  501. /* ***** OTFlags ******/
  502. /*
  503. This type is used to describe bitwise flags in OT data structures
  504. and parameters. Think of it as the OT analogue to the OptionBits
  505. type in "MacTypes.h".
  506. */
  507. typedef UInt32 OTFlags;
  508. /*
  509. These flags are used when sending and receiving data. The
  510. constants defined are masks.
  511. */
  512. enum {
  513. T_MORE = 0x0001, /* More data to come in message */
  514. T_EXPEDITED = 0x0002, /* Data is expedited, if possible */
  515. T_ACKNOWLEDGED = 0x0004, /* Acknowledge transaction */
  516. T_PARTIALDATA = 0x0008, /* Partial data - more coming */
  517. T_NORECEIPT = 0x0010, /* No event on transaction done */
  518. T_TIMEDOUT = 0x0020 /* Reply timed out */
  519. };
  520. /* These flags are used in the TOptMgmt structure to request services.*/
  521. enum {
  522. T_NEGOTIATE = 0x0004,
  523. T_CHECK = 0x0008,
  524. T_DEFAULT = 0x0010,
  525. T_CURRENT = 0x0080
  526. };
  527. /*
  528. These flags are used in the TOptMgmt and TOption structures to
  529. return results.
  530. */
  531. enum {
  532. T_SUCCESS = 0x0020,
  533. T_FAILURE = 0x0040,
  534. T_PARTSUCCESS = 0x0100,
  535. T_READONLY = 0x0200,
  536. T_NOTSUPPORT = 0x0400
  537. };
  538. /*
  539. ***** OTBand *****
  540. A band is a STREAMS concepts which defines the priority of data
  541. on a stream. Although this type is defined as a 32 bit number
  542. for efficiency's sake, bands actually only range from 0 to 255.
  543. Typically band 0 is used for normal data and band 1 for expedited data.
  544. */
  545. typedef UInt32 OTBand;
  546. /* ***** Object References ******/
  547. /*
  548. This deserves some explanation. If you're compiling for
  549. C++, the C++ definitions of TEndpoint and TMapper at the
  550. end of this file are invoked, which lets the compiler
  551. know that they are both subclasses of TProvider. This
  552. way the compiler will do the right subclass type checking,
  553. ie you will be able to pass an EndpointRef to a parameter
  554. of type ProviderRef, but not vice versa.
  555. On the other hand, if your compiling for straighth C,
  556. everything is defined as void. This is somewhat dangerous,
  557. but it prevents you have to cast an EndpointRef to a
  558. ProviderRef every time you call a function that works
  559. on all forms of providers.
  560. */
  561. #ifdef __cplusplus
  562. typedef class TProvider* ProviderRef;
  563. typedef class TEndpoint* EndpointRef;
  564. typedef class TMapper* MapperRef;
  565. #else
  566. typedef void* ProviderRef;
  567. typedef void* EndpointRef;
  568. typedef void* MapperRef;
  569. #endif
  570. #define kOTInvalidRef 0L
  571. #define kOTInvalidProviderRef ((ProviderRef)0L)
  572. #define kOTInvalidEndpointRef ((EndpointRef)0L)
  573. #define kOTInvalidMapperRef ((MapperRef)0L)
  574. /* ***** Event Codes ******/
  575. /*
  576. OT event codes values for Open Transport. These are the event codes that
  577. are sent to notification routine (notifiers).
  578. */
  579. typedef UInt32 OTEventCode;
  580. /*
  581. Events are divided into numerous categories:
  582. 1. (0x0000xxxx) The core XTI events have identifiers of the form
  583. T_XXXX. These signal that an XTI event has occured on a stream.
  584. 2. (0x1000xxxx) Private events are reserved for protocol specific
  585. events. Each protocol stack defines them as appropriate for
  586. its own usage.
  587. 3. (0x2000xxxxx) Completion events have identifiers of the form
  588. T_XXXXCOMPLETE. These signal the completion of some asynchronous
  589. API routine, and are only delivered if the endpoint is in asynchronous
  590. mode.
  591. 4. (0x2100xxxx) Stream events are generally encountered when programming
  592. the raw streams API and indicate some event on a raw stream, or
  593. some other event of interest in the STREAMS kernel.
  594. 5. (0x2200xxxx) Signal events indicate that a signal has arrived on
  595. a raw stream. See "Signal Values" for details.
  596. 6. (0x2300xxxx) General provider events that might be generated by any
  597. provider.
  598. 7. (0x2400xxxx) System events sent to all providers.
  599. 8. (0x2500xxxx) System events sent to registered clients.
  600. 9. (0x2600xxxx) System events used by configurators.
  601. 10. (0x2700xxxx) Events sent to registered OT clients.
  602. */
  603. /*
  604. All event codes not described here are reserved by Apple. If you receive
  605. an event code you do not understand, ignore it!
  606. */
  607. enum {
  608. T_LISTEN = 0x0001, /* An connection request is available */
  609. T_CONNECT = 0x0002, /* Confirmation of a connect request */
  610. T_DATA = 0x0004, /* Standard data is available */
  611. T_EXDATA = 0x0008, /* Expedited data is available */
  612. T_DISCONNECT = 0x0010, /* A disconnect is available */
  613. T_ERROR = 0x0020, /* obsolete/unused in library */
  614. T_UDERR = 0x0040, /* A Unit Data Error has occurred */
  615. T_ORDREL = 0x0080, /* An orderly release is available */
  616. T_GODATA = 0x0100, /* Flow control lifted on standard data */
  617. T_GOEXDATA = 0x0200, /* Flow control lifted on expedited data*/
  618. T_REQUEST = 0x0400, /* An Incoming request is available */
  619. T_REPLY = 0x0800, /* An Incoming reply is available */
  620. T_PASSCON = 0x1000, /* State is now T_DATAXFER */
  621. T_RESET = 0x2000, /* Protocol has been reset */
  622. kPRIVATEEVENT = 0x10000000, /* Base of the private event range.*/
  623. kCOMPLETEEVENT = 0x20000000, /* Base of the completion event range.*/
  624. T_BINDCOMPLETE = 0x20000001, /* Bind call is complete */
  625. T_UNBINDCOMPLETE = 0x20000002, /* Unbind call is complete */
  626. T_ACCEPTCOMPLETE = 0x20000003, /* Accept call is complete */
  627. T_REPLYCOMPLETE = 0x20000004, /* SendReply call is complete */
  628. T_DISCONNECTCOMPLETE = 0x20000005, /* Disconnect call is complete */
  629. T_OPTMGMTCOMPLETE = 0x20000006, /* OptMgmt call is complete */
  630. T_OPENCOMPLETE = 0x20000007, /* An Open call is complete */
  631. T_GETPROTADDRCOMPLETE = 0x20000008, /* GetProtAddress call is complete */
  632. T_RESOLVEADDRCOMPLETE = 0x20000009, /* A ResolveAddress call is complet */
  633. T_GETINFOCOMPLETE = 0x2000000A, /* A GetInfo call is complete */
  634. T_SYNCCOMPLETE = 0x2000000B, /* A Sync call is complete */
  635. T_MEMORYRELEASED = 0x2000000C, /* No-copy memory was released */
  636. T_REGNAMECOMPLETE = 0x2000000D, /* A RegisterName call is complete */
  637. T_DELNAMECOMPLETE = 0x2000000E, /* A DeleteName call is complete */
  638. T_LKUPNAMECOMPLETE = 0x2000000F, /* A LookupName call is complete */
  639. T_LKUPNAMERESULT = 0x20000010, /* A LookupName is returning a name */
  640. kOTSyncIdleEvent = 0x20000011, /* Synchronous call Idle event */
  641. kSTREAMEVENT = 0x21000000, /* Base of the raw stream event range.*/
  642. kOTReservedEvent1 = 0x21000001, /* reserved for internal use by OT */
  643. kGetmsgEvent = 0x21000002, /* A GetMessage call is complete */
  644. kStreamReadEvent = 0x21000003, /* A Read call is complete */
  645. kStreamWriteEvent = 0x21000004, /* A Write call is complete */
  646. kStreamIoctlEvent = 0x21000005, /* An Ioctl call is complete */
  647. kOTReservedEvent2 = 0x21000006, /* reserved for internal use by OT */
  648. kStreamOpenEvent = 0x21000007, /* An OpenStream call is complete */
  649. kPollEvent = 0x21000008, /* A Poll call is complete */
  650. kOTReservedEvent3 = 0x21000009, /* reserved for internal use by OT */
  651. kOTReservedEvent4 = 0x2100000A, /* reserved for internal use by OT */
  652. kOTReservedEvent5 = 0x2100000B, /* reserved for internal use by OT */
  653. kOTReservedEvent6 = 0x2100000C, /* reserved for internal use by OT */
  654. kOTReservedEvent7 = 0x2100000D, /* reserved for internal use by OT */
  655. kOTReservedEvent8 = 0x2100000E, /* reserved for internal use by OT */
  656. kSIGNALEVENT = 0x22000000, /* A signal has arrived on a raw stream, see "Signal Values" below.*/
  657. kPROTOCOLEVENT = 0x23000000, /* Some event from the protocols */
  658. kOTProviderIsDisconnected = 0x23000001, /* Provider is temporarily off-line */
  659. kOTProviderIsReconnected = 0x23000002, /* Provider is now back on-line */
  660. kOTProviderWillClose = 0x24000001, /* Provider will close immediately */
  661. kOTProviderIsClosed = 0x24000002, /* Provider was closed */
  662. kOTPortDisabled = 0x25000001, /* Port is now disabled, result is 0, cookie is port ref */
  663. kOTPortEnabled = 0x25000002, /* Port is now enabled, result is 0, cookie is port ref */
  664. kOTPortOffline = 0x25000003, /* Port is now offline, result is 0, cookie is port ref */
  665. kOTPortOnline = 0x25000004, /* Port is now online, result is 0, cookie is port ref */
  666. kOTClosePortRequest = 0x25000005, /* Request to close/yield, result is reason, cookie is OTPortCloseStruct* */
  667. kOTYieldPortRequest = 0x25000005, /* Request to close/yield, result is reason, cookie is OTPortCloseStruct* */
  668. kOTNewPortRegistered = 0x25000006, /* New port has been registered, cookie is port ref */
  669. kOTPortNetworkChange = 0x25000007, /* Port may have moved to a new network, result is 0, cookie is port ref */
  670. kOTConfigurationChanged = 0x26000001, /* Protocol configuration changed */
  671. kOTSystemSleep = 0x26000002,
  672. kOTSystemShutdown = 0x26000003,
  673. kOTSystemAwaken = 0x26000004,
  674. kOTSystemIdle = 0x26000005,
  675. kOTSystemSleepPrep = 0x26000006,
  676. kOTSystemShutdownPrep = 0x26000007,
  677. kOTSystemAwakenPrep = 0x26000008,
  678. kOTStackIsLoading = 0x27000001, /* Sent before Open Transport attempts to load the TCP/IP protocol stack.*/
  679. kOTStackWasLoaded = 0x27000002, /* Sent after the TCP/IP stack has been successfully loaded.*/
  680. kOTStackIsUnloading = 0x27000003 /* Sent before Open Transport unloads the TCP/IP stack.*/
  681. };
  682. /* ***** Event Classification Macros ***** */
  683. #define IsOTPrivateEvent(x) (((x) & 0x70000000L) == kPRIVATEEVENT)
  684. #define IsOTCompleteEvent(x) (((x) & 0x7f000000L) == kCOMPLETEEVENT)
  685. #define IsOTProtocolEvent(x) (((x) & 0x7f000000L) == kPROTOCOLEVENT)
  686. #define IsOTStreamEvent(x) (((x) & 0x7f000000L) == kSTREAMEVENT)
  687. #define IsOTSignalEvent(x) (((x) & 0x7f000000L) == kSIGNALEVENT)
  688. #define GetOTEventCode(x) (x)
  689. /*
  690. ***** Signal Values *****
  691. Signals that are generated by a raw stream. When writing a notifier
  692. for a raw stream, add these values to kSIGNALEVENT to determine what
  693. event you are receiving.
  694. */
  695. enum {
  696. kSIGHUP = 1,
  697. kSIGURG = 16,
  698. kSIGPOLL = 30
  699. };
  700. enum {
  701. SIGHUP = kSIGHUP,
  702. SIGURG = kSIGURG,
  703. SIGPOLL = kSIGPOLL
  704. };
  705. /*
  706. ***** Notifier Type Definition *****
  707. Open Transport notifiers must conform to the OTNotifyProcPtr prototype.
  708. Even though a OTNotifyUPP is a OTNotifyProcPtr on pre-Carbon system,
  709. use NewOTNotifyUPP() and friends to make your source code portable to OS X and Carbon.
  710. */
  711. typedef CALLBACK_API( void , OTNotifyProcPtr )(void *contextPtr, OTEventCode code, OTResult result, void *cookie);
  712. typedef TVECTOR_UPP_TYPE(OTNotifyProcPtr) OTNotifyUPP;
  713. /*
  714. * NewOTNotifyUPP()
  715. *
  716. * Availability:
  717. * Non-Carbon CFM: available as macro/inline
  718. * CarbonLib: in CarbonLib 1.0 and later
  719. * Mac OS X: in version 10.0 and later
  720. */
  721. EXTERN_API_C( OTNotifyUPP )
  722. NewOTNotifyUPP(OTNotifyProcPtr userRoutine);
  723. #if !OPAQUE_UPP_TYPES
  724. enum { uppOTNotifyProcInfo = 0x00003FC0 }; /* pascal no_return_value Func(4_bytes, 4_bytes, 4_bytes, 4_bytes) */
  725. #ifdef __cplusplus
  726. inline DEFINE_API_C(OTNotifyUPP) NewOTNotifyUPP(OTNotifyProcPtr userRoutine) { return userRoutine; }
  727. #else
  728. #define NewOTNotifyUPP(userRoutine) (userRoutine)
  729. #endif
  730. #endif
  731. /*
  732. * DisposeOTNotifyUPP()
  733. *
  734. * Availability:
  735. * Non-Carbon CFM: available as macro/inline
  736. * CarbonLib: in CarbonLib 1.0 and later
  737. * Mac OS X: in version 10.0 and later
  738. */
  739. EXTERN_API_C( void )
  740. DisposeOTNotifyUPP(OTNotifyUPP userUPP);
  741. #if !OPAQUE_UPP_TYPES
  742. #ifdef __cplusplus
  743. inline DEFINE_API_C(void) DisposeOTNotifyUPP(OTNotifyUPP) {}
  744. #else
  745. #define DisposeOTNotifyUPP(userUPP)
  746. #endif
  747. #endif
  748. /*
  749. * InvokeOTNotifyUPP()
  750. *
  751. * Availability:
  752. * Non-Carbon CFM: available as macro/inline
  753. * CarbonLib: in CarbonLib 1.0 and later
  754. * Mac OS X: in version 10.0 and later
  755. */
  756. EXTERN_API_C( void )
  757. InvokeOTNotifyUPP(
  758. void * contextPtr,
  759. OTEventCode code,
  760. OTResult result,
  761. void * cookie,
  762. OTNotifyUPP userUPP);
  763. #if !OPAQUE_UPP_TYPES
  764. #ifdef __cplusplus
  765. inline DEFINE_API_C(void) InvokeOTNotifyUPP(void * contextPtr, OTEventCode code, OTResult result, void * cookie, OTNotifyUPP userUPP) { (*userUPP)(contextPtr, code, result, cookie); }
  766. #else
  767. #define InvokeOTNotifyUPP(contextPtr, code, result, cookie, userUPP) (*userUPP)(contextPtr, code, result, cookie)
  768. #endif
  769. #endif
  770. /* ***** Option Management Definitions ******/
  771. /* The XTI Level number of a protocol.*/
  772. enum {
  773. XTI_GENERIC = 0xFFFF /* level for XTI options */
  774. };
  775. typedef UInt32 OTXTILevel;
  776. /* The XTI name of a protocol option.*/
  777. typedef UInt32 OTXTIName;
  778. /* XTI names for options used with XTI_GENERIC above*/
  779. enum {
  780. XTI_DEBUG = 0x0001,
  781. XTI_LINGER = 0x0080,
  782. XTI_RCVBUF = 0x1002,
  783. XTI_RCVLOWAT = 0x1004,
  784. XTI_SNDBUF = 0x1001,
  785. XTI_SNDLOWAT = 0x1003,
  786. XTI_PROTOTYPE = 0x1005,
  787. OPT_CHECKSUM = 0x0600, /* Set checksumming = UInt32 - 0 or 1)*/
  788. OPT_RETRYCNT = 0x0601, /* Set a retry counter = UInt32 (0 = infinite)*/
  789. OPT_INTERVAL = 0x0602, /* Set a retry interval = UInt32 milliseconds*/
  790. OPT_ENABLEEOM = 0x0603, /* Enable the EOM indication = UInt8 (0 or 1)*/
  791. OPT_SELFSEND = 0x0604, /* Enable Self-sending on broadcasts = UInt32 (0 or 1)*/
  792. OPT_SERVERSTATUS = 0x0605, /* Set Server Status (format is proto dependent)*/
  793. OPT_ALERTENABLE = 0x0606, /* Enable/Disable protocol alerts*/
  794. OPT_KEEPALIVE = 0x0008 /* See t_keepalive structure*/
  795. };
  796. /* ***** Ioctl Definitions ******/
  797. /*
  798. All OT ioctl numbers are formed using the MIOC_CMD macro,
  799. which divides the ioctl space by protocol space (the
  800. first parameter) and ioctl number within that protocol
  801. space (the second parameter). This macro is only available
  802. to C users but it's relatively easy to synthesise its
  803. results in other languages.
  804. */
  805. #define MIOC_CMD(t,v) ((((t)&0xFF) << 8) | ((v)&0xFF))
  806. /* The following is a registry of the ioctls protocol spaces.*/
  807. enum {
  808. MIOC_STREAMIO = 'A', /* Basic Stream ioctl() cmds - I_PUSH, I_LOOK, etc. */
  809. MIOC_TMOD = 'a', /* ioctl's for tmod test module */
  810. MIOC_STRLOG = 'b', /* ioctl's for Mentat's log device */
  811. MIOC_ND = 'c', /* ioctl's for Mentat's nd device */
  812. MIOC_ECHO = 'd', /* ioctl's for Mentat's echo device */
  813. MIOC_TLI = 'e', /* ioctl's for Mentat's timod module */
  814. MIOC_RESERVEDf = 'f', /* reserved, used by SVR4 FIOxxx */
  815. MIOC_SAD = 'g', /* ioctl's for Mentat's sad module */
  816. MIOC_ARP = 'h', /* ioctl's for Mentat's arp module */
  817. MIOC_HAVOC = 'H', /* Havoc module ioctls. */
  818. MIOC_RESERVEDi = 'i', /* reserved, used by SVR4 SIOCxxx */
  819. MIOC_SIOC = 'j', /* sockio.h socket ioctl's */
  820. MIOC_TCP = 'k', /* tcp.h ioctl's */
  821. MIOC_DLPI = 'l', /* dlpi.h additions */
  822. MIOC_SOCKETS = 'm', /* Mentat sockmod ioctl's */
  823. MIOC_IPX = 'o', /* ioctls for IPX */
  824. MIOC_OT = 'O', /* ioctls for Open Transport */
  825. MIOC_ATALK = 'T', /* ioctl's for AppleTalk */
  826. MIOC_SRL = 'U', /* ioctl's for Serial */
  827. MIOC_RESERVEDp = 'p', /* reserved, used by SVR4 */
  828. MIOC_RESERVEDr = 'r', /* reserved, used by SVR4 */
  829. MIOC_RESERVEDs = 's', /* reserved, used by SVR4 */
  830. MIOC_CFIG = 'z' /* ioctl's for private configuration */
  831. };
  832. /* OT specific ioctls.*/
  833. enum {
  834. I_OTGetMiscellaneousEvents = ((MIOC_OT << 8) | 1), /* sign up for Misc Events */
  835. I_OTSetFramingType = ((MIOC_OT << 8) | 2), /* Set framing option for link */
  836. kOTGetFramingValue = (unsigned long)0xFFFFFFFF, /* Use this value to read framing */
  837. I_OTSetRawMode = ((MIOC_OT << 8) | 3), /* Set raw mode for link */
  838. kOTSetRecvMode = 0x01,
  839. kOTSendErrorPacket = 0x02,
  840. I_OTConnect = ((MIOC_OT << 8) | 4), /* Generic connect request for links */
  841. I_OTDisconnect = ((MIOC_OT << 8) | 5), /* Generic disconnect request for links */
  842. I_OTScript = ((MIOC_OT << 8) | 6) /* Send a script to a module */
  843. };
  844. /* Structure for the I_OTScript Ioctl.*/
  845. struct OTScriptInfo {
  846. UInt32 fScriptType;
  847. void * fTheScript;
  848. UInt32 fScriptLength;
  849. };
  850. typedef struct OTScriptInfo OTScriptInfo;
  851. /*
  852. ***** XTI States *****
  853. These are the potential values returned by OTGetEndpointState and OTSync
  854. which represent the XTI state of an endpoint.
  855. */
  856. typedef UInt32 OTXTIStates;
  857. enum {
  858. T_UNINIT = 0, /* addition to standard xti.h */
  859. T_UNBND = 1, /* unbound */
  860. T_IDLE = 2, /* idle */
  861. T_OUTCON = 3, /* outgoing connection pending */
  862. T_INCON = 4, /* incoming connection pending */
  863. T_DATAXFER = 5, /* data transfer */
  864. T_OUTREL = 6, /* outgoing orderly release */
  865. T_INREL = 7 /* incoming orderly release */
  866. };
  867. /*
  868. ***** General XTI Definitions *****
  869. These definitions are typically used during option management.
  870. */
  871. enum {
  872. T_YES = 1,
  873. T_NO = 0,
  874. T_UNUSED = (unsigned long)(-1),
  875. kT_NULL = 0,
  876. T_ABSREQ = 0x8000
  877. };
  878. enum {
  879. kT_UNSPEC = (unsigned long)0xFFFFFFFD,
  880. T_ALLOPT = 0
  881. };
  882. enum {
  883. T_NULL = kT_NULL,
  884. T_UNSPEC = kT_UNSPEC
  885. };
  886. /*
  887. ***** OTConfiguration *****
  888. This is a "black box" structure used to define the configuration of a
  889. provider or endpoint. This file defines a very limited set of operations
  890. on a configuration. "OpenTransportClient.h" extends this with extra
  891. operations used by protocol stacks but not typically needed by clients.
  892. */
  893. #ifdef __cplusplus
  894. typedef class OTConfiguration* OTConfigurationRef;
  895. #else
  896. typedef struct OTConfiguration* OTConfigurationRef;
  897. #endif
  898. #define kOTNoMemoryConfigurationPtr ((OTConfigurationRef)0L)
  899. #define kOTInvalidConfigurationPtr ((OTConfigurationRef)-1L)
  900. /* ***** Option Management Structures ******/
  901. /* This structure describes the contents of a single option in a buffer.*/
  902. struct TOptionHeader {
  903. ByteCount len; /* total length of option */
  904. /* = sizeof(TOptionHeader) + length */
  905. /* of option value in bytes */
  906. OTXTILevel level; /* protocol affected */
  907. OTXTIName name; /* option name */
  908. UInt32 status; /* status value */
  909. };
  910. typedef struct TOptionHeader TOptionHeader;
  911. /*
  912. This structure describes the contents of a single option in a buffer.
  913. It differs from TOptionHeader in that it includes the value field,
  914. which acts as an unbounded array representing the value of the option.
  915. */
  916. struct TOption {
  917. ByteCount len; /* total length of option */
  918. /* = sizeof(TOption) + length */
  919. /* of option value in bytes */
  920. OTXTILevel level; /* protocol affected */
  921. OTXTIName name; /* option name */
  922. UInt32 status; /* status value */
  923. UInt32 value[1]; /* data goes here */
  924. };
  925. typedef struct TOption TOption;
  926. /* Some useful constants when manipulating option buffers.*/
  927. enum {
  928. kOTOptionHeaderSize = sizeof(TOptionHeader),
  929. kOTBooleanOptionDataSize = sizeof(UInt32),
  930. kOTBooleanOptionSize = kOTOptionHeaderSize + kOTBooleanOptionDataSize,
  931. kOTOneByteOptionSize = kOTOptionHeaderSize + 1,
  932. kOTTwoByteOptionSize = kOTOptionHeaderSize + 2,
  933. kOTFourByteOptionSize = kOTOptionHeaderSize + sizeof(UInt32)
  934. };
  935. /*
  936. This macro will align return the value of "len", rounded up to the next
  937. 4-byte boundary.
  938. */
  939. #define T_ALIGN(len) (((UInt32)(len)+(sizeof(SInt32)-1)) & ~(sizeof(SInt32)-1))
  940. /*
  941. This macro will return the next option in the buffer, given the previous option
  942. in the buffer, returning NULL if there are no more.
  943. You start off by setting prevOption = (TOption*)theBuffer
  944. (Use OTNextOption for a more thorough check - it ensures the end
  945. of the option is in the buffer as well.)
  946. */
  947. #define OPT_NEXTHDR(theBuffer, theBufLen, prevOption) \
  948. (((char*)(prevOption) + T_ALIGN((prevOption)->len) < (char*)(theBuffer) + (theBufLen)) ? \
  949. (TOption*)((char*)(prevOption)+T_ALIGN((prevOption)->len)) \
  950. : (TOption*)NULL)
  951. /* t_kpalive is used with OPT_KEEPALIVE option.*/
  952. struct t_kpalive {
  953. SInt32 kp_onoff; /* option on/off */
  954. SInt32 kp_timeout; /* timeout in minutes */
  955. };
  956. typedef struct t_kpalive t_kpalive;
  957. /* t_linger is used with XTI_LINGER option.*/
  958. struct t_linger {
  959. SInt32 l_onoff; /* option on/off */
  960. SInt32 l_linger; /* linger time */
  961. };
  962. typedef struct t_linger t_linger;
  963. /*
  964. ***** TEndpointInfo *****
  965. This structure is returned from the GetEndpointInfo call and contains
  966. information about an endpoint. But first, some special flags and types.
  967. */
  968. /* Values returned in servtype field of TEndpointInfo.*/
  969. typedef UInt32 OTServiceType;
  970. enum {
  971. T_COTS = 1, /* Connection-mode service */
  972. T_COTS_ORD = 2, /* Connection service with orderly release */
  973. T_CLTS = 3, /* Connectionless-mode service */
  974. T_TRANS = 5, /* Connection-mode transaction service */
  975. T_TRANS_ORD = 6, /* Connection transaction service with orderly release */
  976. T_TRANS_CLTS = 7 /* Connectionless transaction service */
  977. };
  978. /* Masks for the flags field of TEndpointInfo.*/
  979. enum {
  980. T_SENDZERO = 0x0001, /* supports 0-length TSDU's */
  981. T_XPG4_1 = 0x0002, /* supports the GetProtAddress call */
  982. T_CAN_SUPPORT_MDATA = 0x10000000, /* support M_DATAs on packet protocols */
  983. T_CAN_RESOLVE_ADDR = 0x40000000, /* Supports ResolveAddress call */
  984. T_CAN_SUPPLY_MIB = 0x20000000 /* Supports SNMP MIB data */
  985. };
  986. /*
  987. Special-case values for in the tsdu, etsdu, connect, and discon
  988. fields of TEndpointInfo.
  989. */
  990. enum {
  991. T_INFINITE = -1, /* supports infinit amounts of data */
  992. T_INVALID = -2 /* Does not support data transmission */
  993. };
  994. typedef SInt32 OTDataSize;
  995. /* Now the TEndpointInfo structure proper.*/
  996. struct TEndpointInfo {
  997. OTDataSize addr; /* Maximum size of an address */
  998. OTDataSize options; /* Maximum size of options */
  999. OTDataSize tsdu; /* Standard data transmit unit size */
  1000. OTDataSize etsdu; /* Expedited data transmit unit size */
  1001. OTDataSize connect; /* Maximum data size on connect */
  1002. OTDataSize discon; /* Maximum data size on disconnect */
  1003. OTServiceType servtype; /* service type */
  1004. UInt32 flags; /* Flags (see above for values) */
  1005. };
  1006. typedef struct TEndpointInfo TEndpointInfo;
  1007. /*
  1008. "OpenTransport.h" no longer defines "struct t_info". We recommend
  1009. that you use TEndpointInfo instead. If this is impossible, use
  1010. the definition of "struct t_info" in "OpenTransportXTI.h".
  1011. */
  1012. /* ***** OTPortRecord ******/
  1013. /* Unique identifier for a port.*/
  1014. typedef UInt32 OTPortRef;
  1015. typedef OTPortRef * OTPortRefPtr;
  1016. enum {
  1017. kOTInvalidPortRef = 0
  1018. };
  1019. /* Valid values for the bus type element of an OTPortRef.*/
  1020. typedef UInt8 OTBusType;
  1021. enum {
  1022. kOTUnknownBusPort = 0,
  1023. kOTMotherboardBus = 1,
  1024. kOTNuBus = 2,
  1025. kOTPCIBus = 3,
  1026. kOTGeoPort = 4,
  1027. kOTPCCardBus = 5,
  1028. kOTFireWireBus = 6,
  1029. kOTLastBusIndex = 15
  1030. };
  1031. /*
  1032. A couple of special values for the device type element of an
  1033. OTPortRef. See "OpenTransportDevices.h" for the standard values.
  1034. */
  1035. typedef UInt16 OTDeviceType;
  1036. enum {
  1037. kOTNoDeviceType = 0,
  1038. kOTADEVDevice = 1, /* An Atalk ADEV */
  1039. kOTMDEVDevice = 2, /* A TCP/IP MDEV */
  1040. kOTLocalTalkDevice = 3, /* LocalTalk */
  1041. kOTIRTalkDevice = 4, /* IRTalk */
  1042. kOTTokenRingDevice = 5, /* Token Ring */
  1043. kOTISDNDevice = 6, /* ISDN */
  1044. kOTATMDevice = 7, /* ATM */
  1045. kOTSMDSDevice = 8, /* SMDS */
  1046. kOTSerialDevice = 9, /* Serial */
  1047. kOTEthernetDevice = 10, /* Ethernet */
  1048. kOTSLIPDevice = 11, /* SLIP Pseudo-device */
  1049. kOTPPPDevice = 12, /* PPP Pseudo-device */
  1050. kOTModemDevice = 13, /* Modem Pseudo-Device */
  1051. kOTFastEthernetDevice = 14, /* 100 MB Ethernet */
  1052. kOTFDDIDevice = 15, /* FDDI */
  1053. kOTIrDADevice = 16, /* IrDA Infrared */
  1054. kOTATMSNAPDevice = 17, /* ATM SNAP emulation */
  1055. kOTFibreChannelDevice = 18, /* Fibre Channel */
  1056. kOTFireWireDevice = 19, /* FireWire link Device */
  1057. kOTPseudoDevice = 1023, /* used where no other defined device type will work*/
  1058. kOTLastDeviceIndex = 1022
  1059. };
  1060. /* Special case values for the slot number element of an OTPortRef.*/
  1061. enum {
  1062. kOTLastSlotNumber = 255,
  1063. kOTLastOtherNumber = 255
  1064. };
  1065. typedef UInt16 OTSlotNumber;
  1066. /* Accessor functions for the various elements of the OTPortRef.*/
  1067. /*
  1068. * OTCreatePortRef()
  1069. *
  1070. * Availability:
  1071. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  1072. * CarbonLib: in CarbonLib 1.0 and later
  1073. * Mac OS X: in version 10.0 and later
  1074. */
  1075. EXTERN_API( OTPortRef )
  1076. OTCreatePortRef(
  1077. OTBusType busType,
  1078. OTDeviceType devType,
  1079. OTSlotNumber slot,
  1080. UInt16 other);
  1081. /*
  1082. * OTGetDeviceTypeFromPortRef()
  1083. *
  1084. * Availability:
  1085. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  1086. * CarbonLib: in CarbonLib 1.0 and later
  1087. * Mac OS X: in version 10.0 and later
  1088. */
  1089. EXTERN_API( OTDeviceType )
  1090. OTGetDeviceTypeFromPortRef(OTPortRef ref);
  1091. /*
  1092. * OTGetBusTypeFromPortRef()
  1093. *
  1094. * Availability:
  1095. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  1096. * CarbonLib: in CarbonLib 1.0 and later
  1097. * Mac OS X: in version 10.0 and later
  1098. */
  1099. EXTERN_API( UInt16 )
  1100. OTGetBusTypeFromPortRef(OTPortRef ref);
  1101. /*
  1102. * OTGetSlotFromPortRef()
  1103. *
  1104. * Availability:
  1105. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  1106. * CarbonLib: in CarbonLib 1.0 and later
  1107. * Mac OS X: in version 10.0 and later
  1108. */
  1109. EXTERN_API( OTSlotNumber )
  1110. OTGetSlotFromPortRef(
  1111. OTPortRef ref,
  1112. UInt16 * other);
  1113. /*
  1114. * OTSetDeviceTypeInPortRef()
  1115. *
  1116. * Availability:
  1117. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  1118. * CarbonLib: in CarbonLib 1.0 and later
  1119. * Mac OS X: in version 10.0 and later
  1120. */
  1121. EXTERN_API( OTPortRef )
  1122. OTSetDeviceTypeInPortRef(
  1123. OTPortRef ref,
  1124. OTDeviceType devType);
  1125. /*
  1126. * OTSetBusTypeInPortRef()
  1127. *
  1128. * Availability:
  1129. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  1130. * CarbonLib: in CarbonLib 1.0 and later
  1131. * Mac OS X: in version 10.0 and later
  1132. */
  1133. EXTERN_API( OTPortRef )
  1134. OTSetBusTypeInPortRef(
  1135. OTPortRef ref,
  1136. OTBusType busType);
  1137. /*
  1138. Convenience macros for generating specific types of OTPortRefs.
  1139. */
  1140. #define OTCreateNuBusPortRef(devType, slot, other) \
  1141. OTCreatePortRef(kOTNuBus, devType, slot, other)
  1142. #define OTCreatePCIPortRef(devType, slot, other) \
  1143. OTCreatePortRef(kOTPCIBus, devType, slot, other)
  1144. #define OTCreatePCCardPortRef(devType, slot, other) \
  1145. OTCreatePortRef(kOTPCCardBus, devType, slot, other)
  1146. /* Name length definitions for various fields in OTPortRecord.*/
  1147. enum {
  1148. kMaxModuleNameLength = 31, /* max length of a STREAMS module name*/
  1149. kMaxModuleNameSize = kMaxModuleNameLength + 1,
  1150. kMaxProviderNameLength = kMaxModuleNameLength + 4, /* providers allow 4 characters for minor number*/
  1151. kMaxProviderNameSize = kMaxProviderNameLength + 1,
  1152. kMaxSlotIDLength = 7, /* PCI slot names tend to be short*/
  1153. kMaxSlotIDSize = kMaxSlotIDLength + 1,
  1154. kMaxResourceInfoLength = 31, /* max length of a configuration helper name*/
  1155. kMaxResourceInfoSize = 32,
  1156. kMaxPortNameLength = kMaxModuleNameLength + 4, /* max size allowed to define a port*/
  1157. kMaxPortNameSize = kMaxPortNameLength + 1
  1158. };
  1159. /*
  1160. Masks for the fPortFlags field of OTPortRecord
  1161. If no bits are set, the port is currently inactive.
  1162. */
  1163. enum {
  1164. kOTPortIsActive = 0x00000001,
  1165. kOTPortIsDisabled = 0x00000002,
  1166. kOTPortIsUnavailable = 0x00000004,
  1167. kOTPortIsOffline = 0x00000008
  1168. };
  1169. /* Masks for the fInfoFlags field of the OTPortRecord.*/
  1170. enum {
  1171. kOTPortIsDLPI = 0x00000001,
  1172. kOTPortIsTPI = 0x00000002,
  1173. kOTPortCanYield = 0x00000004, /* will not be set until the port is used for the first time*/
  1174. kOTPortCanArbitrate = 0x00000008, /* will not be set until the port is used for the first time*/
  1175. kOTPortIsTransitory = 0x00000010,
  1176. kOTPortAutoConnects = 0x00000020,
  1177. kOTPortIsSystemRegistered = 0x00004000,
  1178. kOTPortIsPrivate = 0x00008000,
  1179. kOTPortIsAlias = (unsigned long)0x80000000
  1180. };
  1181. /*
  1182. One OTPortRecord is created for each instance of a port.
  1183. For Instance 'enet' identifies an ethernet port.
  1184. A OTPortRecord for each ethernet card it finds, with an
  1185. OTPortRef that will uniquely allow the driver to determine which
  1186. port it is supposed to open on.
  1187. */
  1188. struct OTPortRecord {
  1189. OTPortRef fRef;
  1190. UInt32 fPortFlags;
  1191. UInt32 fInfoFlags;
  1192. UInt32 fCapabilities;
  1193. ItemCount fNumChildPorts;
  1194. OTPortRef * fChildPorts;
  1195. char fPortName[36];
  1196. char fModuleName[32];
  1197. char fSlotID[8];
  1198. char fResourceInfo[32];
  1199. char fReserved[164];
  1200. };
  1201. typedef struct OTPortRecord OTPortRecord;
  1202. /*
  1203. Routines for finding, registering and unregistering ports.
  1204. IMPORTANT:
  1205. These routines have two versions, one for the client and one
  1206. for the kernel. Make sure you use and link with the right ones.
  1207. */
  1208. #if !OTKERNEL
  1209. /*
  1210. * OTGetIndexedPort()
  1211. *
  1212. * Availability:
  1213. * Non-Carbon CFM: in OTClientUtilLib 1.0 and later
  1214. * CarbonLib: in CarbonLib 1.0 and later
  1215. * Mac OS X: in version 10.0 and later
  1216. */
  1217. EXTERN_API( Boolean )
  1218. OTGetIndexedPort(
  1219. OTPortRecord * portRecord,
  1220. OTItemCount index);
  1221. /* Index through the ports in the system*/
  1222. /*
  1223. * OTFindPort()
  1224. *
  1225. * Availability:
  1226. * Non-Carbon CFM: in OTClientUtilLib 1.0 and later
  1227. * CarbonLib: in CarbonLib 1.0 and later
  1228. * Mac OS X: in version 10.0 and later
  1229. */
  1230. EXTERN_API( Boolean )
  1231. OTFindPort(
  1232. OTPortRecord * portRecord,
  1233. const char * portName);
  1234. /* Find an OTPortRecord for a port using it's name*/
  1235. /*
  1236. * OTFindPortByRef()
  1237. *
  1238. * Availability:
  1239. * Non-Carbon CFM: in OTClientUtilLib 1.0 and later
  1240. * CarbonLib: in CarbonLib 1.0 and later
  1241. * Mac OS X: in version 10.0 and later
  1242. */
  1243. EXTERN_API( Boolean )
  1244. OTFindPortByRef(
  1245. OTPortRecord * portRecord,
  1246. OTPortRef ref);
  1247. /* Find an OTPortRecord for a port using it's OTPortRef*/
  1248. #if CALL_NOT_IN_CARBON
  1249. /*
  1250. * OTRegisterPort()
  1251. *
  1252. * Availability:
  1253. * Non-Carbon CFM: in OTClientUtilLib 1.0 and later
  1254. * CarbonLib: not available
  1255. * Mac OS X: not available
  1256. */
  1257. EXTERN_API_C( OSStatus )
  1258. OTRegisterPort(
  1259. OTPortRecord * portRecord,
  1260. void * ref);
  1261. /*
  1262. Register a port. The name the port was registered under is returned in
  1263. the fPortName field.
  1264. */
  1265. /*
  1266. * OTUnregisterPort()
  1267. *
  1268. * Availability:
  1269. * Non-Carbon CFM: in OTClientUtilLib 1.0 and later
  1270. * CarbonLib: not available
  1271. * Mac OS X: not available
  1272. */
  1273. EXTERN_API_C( OSStatus )
  1274. OTUnregisterPort(
  1275. const char * portName,
  1276. void ** ref);
  1277. /*
  1278. Unregister the port with the given name (If you re-register the
  1279. port, it may get a different name - use OTChangePortState if
  1280. that is not desireable). Since a single OTPortRef can be registered
  1281. with several names, the API needs to use the portName rather than
  1282. the OTPortRef to disambiguate.
  1283. */
  1284. /*
  1285. * OTChangePortState()
  1286. *
  1287. * Availability:
  1288. * Non-Carbon CFM: in OTClientUtilLib 1.0 and later
  1289. * CarbonLib: not available
  1290. * Mac OS X: not available
  1291. */
  1292. EXTERN_API_C( OSStatus )
  1293. OTChangePortState(
  1294. OTPortRef portRef,
  1295. OTEventCode theChange,
  1296. OTResult why);
  1297. /* Change the state of the port.*/
  1298. #endif /* CALL_NOT_IN_CARBON */
  1299. #endif /* !OTKERNEL */
  1300. /* ***** Data Buffers ******/
  1301. /*
  1302. TNetbuf is the basic structure used to pass data back and forth
  1303. between the Open Transport protocols and their clients
  1304. */
  1305. struct TNetbuf {
  1306. ByteCount maxlen;
  1307. ByteCount len;
  1308. UInt8 * buf;
  1309. };
  1310. typedef struct TNetbuf TNetbuf;
  1311. /*
  1312. Some rarely used low-level routines in this file take a strbuf
  1313. as a parameter. This is the raw streams equivalent of a TNetbuf.
  1314. The key difference is that the maxlen and len fields are signed,
  1315. which allows you to specify extra operations by providing a
  1316. negative value.
  1317. */
  1318. struct strbuf {
  1319. SInt32 maxlen; /* max buffer length */
  1320. SInt32 len; /* length of data */
  1321. char * buf; /* pointer to buffer */
  1322. };
  1323. typedef struct strbuf strbuf;
  1324. /*
  1325. OTData is used in a TNetbuf or netbuf to send
  1326. non-contiguous data. Set the 'len' field of the netbuf to the
  1327. constant kNetbufDataIsOTData to signal that the 'buf' field of the
  1328. netbuf actually points to one of these structures instead of a
  1329. memory buffer.
  1330. */
  1331. struct OTData {
  1332. void * fNext;
  1333. void * fData;
  1334. ByteCount fLen;
  1335. };
  1336. typedef struct OTData OTData;
  1337. enum {
  1338. kNetbufDataIsOTData = (unsigned long)0xFFFFFFFE
  1339. };
  1340. /*
  1341. OTBuffer is used for no-copy receives. When receiving, you can
  1342. set the receive length to kOTNetbufDataIsOTBufferStar and then
  1343. pass the address of an OTBuffer* as the receive buffer. OT will
  1344. fill it out to point to a chain of OTBuffers.
  1345. When you are done with it, you must call the OTReleaseBuffer function.
  1346. For best performance, you need to call OTReleaseBuffer quickly.
  1347. Only data netbufs may use this - no netbufs for addresses or options, or the like.
  1348. Any OTBuffer returned to you by OT is read only!
  1349. The astute will notice that this has a high correlation with the
  1350. STREAMS msgb data type. The fields are commented with their
  1351. corresponding msgb field name.
  1352. */
  1353. struct OTBuffer {
  1354. void * fLink; /* b_next*/
  1355. void * fLink2; /* b_prev*/
  1356. struct OTBuffer * fNext; /* b_cont*/
  1357. UInt8 * fData; /* b_rptr*/
  1358. ByteCount fLen; /* b_wptr*/
  1359. void * fSave; /* b_datap*/
  1360. UInt8 fBand; /* b_band*/
  1361. UInt8 fType; /* b_pad1*/
  1362. UInt8 fPad1;
  1363. UInt8 fFlags; /* b_flag*/
  1364. };
  1365. typedef struct OTBuffer OTBuffer;
  1366. enum {
  1367. kOTNetbufDataIsOTBufferStar = (unsigned long)0xFFFFFFFD
  1368. };
  1369. /*
  1370. OTBufferInfo is used with OTReadBuffer to keep track of where you
  1371. are in the buffer, since the OTBuffer is "read-only".
  1372. */
  1373. /* Use the OTInitBuffer macro to initialise this structure from an OTBuffer chain.*/
  1374. struct OTBufferInfo {
  1375. OTBuffer * fBuffer;
  1376. ByteCount fOffset;
  1377. UInt8 fPad;
  1378. };
  1379. typedef struct OTBufferInfo OTBufferInfo;
  1380. #define OTInitBufferInfo(infoPtr, theBuffer) \
  1381. (infoPtr)->fBuffer = theBuffer; \
  1382. (infoPtr)->fPad = (theBuffer)->fPad1; \
  1383. (infoPtr)->fOffset = 0
  1384. /*
  1385. If the endpoint supports "raw mode" (the T_CAN_SUPPORT_MDATA bit will
  1386. be set in the TEndpointInfo::flags field), then you specify the
  1387. raw mode packet by putting the kOTNetbufIsRawMode value in
  1388. the udata.addr.len field when calling OTSndUData and also set the
  1389. udata.opt.len, udata.opt.buf, and udata.addr.buf fields to 0.
  1390. */
  1391. enum {
  1392. kOTNetbufIsRawMode = (unsigned long)0xFFFFFFFF
  1393. };
  1394. /*
  1395. ***** Standard XTI Parameter Types *****
  1396. These structures are all used as parameters to the standard
  1397. XTI routines.
  1398. */
  1399. /*
  1400. TBind holds binding information for calls to
  1401. OTGetProtAddress, OTResolveAddress and OTBind.
  1402. */
  1403. struct TBind {
  1404. TNetbuf addr;
  1405. OTQLen qlen;
  1406. };
  1407. typedef struct TBind TBind;
  1408. /*
  1409. TDiscon is passed to RcvDisconnect to find out additional information
  1410. about the disconnect.
  1411. */
  1412. struct TDiscon {
  1413. TNetbuf udata;
  1414. OTReason reason;
  1415. OTSequence sequence;
  1416. };
  1417. typedef struct TDiscon TDiscon;
  1418. /*
  1419. TCall holds information about a connection and is a parameter to
  1420. OTConnect, OTRcvConnect, OTListen, OTAccept, and OTSndDisconnect.
  1421. */
  1422. struct TCall {
  1423. TNetbuf addr;
  1424. TNetbuf opt;
  1425. TNetbuf udata;
  1426. OTSequence sequence;
  1427. };
  1428. typedef struct TCall TCall;
  1429. /* TUnitData describes a datagram in calls to OTSndUData and OTRcvUData.*/
  1430. struct TUnitData {
  1431. TNetbuf addr;
  1432. TNetbuf opt;
  1433. TNetbuf udata;
  1434. };
  1435. typedef struct TUnitData TUnitData;
  1436. /*
  1437. TUDErr is used to get information about a datagram error using
  1438. OTRcvUDErr.
  1439. */
  1440. struct TUDErr {
  1441. TNetbuf addr;
  1442. TNetbuf opt;
  1443. SInt32 error;
  1444. };
  1445. typedef struct TUDErr TUDErr;
  1446. /* TOptMgmt is passed to the OTOptionManagement call to read or set protocol*/
  1447. struct TOptMgmt {
  1448. TNetbuf opt;
  1449. OTFlags flags;
  1450. };
  1451. typedef struct TOptMgmt TOptMgmt;
  1452. /*
  1453. ***** Transactional XTI Parameter Types *****
  1454. These structures are all used as parameters to the OT's
  1455. XTI-like routines for transaction protocols.
  1456. */
  1457. /*
  1458. TRequest is passed to OTSndRequest and OTRcvRequest that contains the information
  1459. about the request.
  1460. */
  1461. struct TRequest {
  1462. TNetbuf data;
  1463. TNetbuf opt;
  1464. OTSequence sequence;
  1465. };
  1466. typedef struct TRequest TRequest;
  1467. /* TReply is passed to OTSndReply to send a reply to an incoming request.*/
  1468. struct TReply {
  1469. TNetbuf data;
  1470. TNetbuf opt;
  1471. OTSequence sequence;
  1472. };
  1473. typedef struct TReply TReply;
  1474. /*
  1475. TUnitRequest is passed to OTSndURequest and OTRcvURequest that contains
  1476. the information about the request.
  1477. */
  1478. struct TUnitRequest {
  1479. TNetbuf addr;
  1480. TNetbuf opt;
  1481. TNetbuf udata;
  1482. OTSequence sequence;
  1483. };
  1484. typedef struct TUnitRequest TUnitRequest;
  1485. /* TUnitReply is passed to OTSndUReply to send a reply to an incoming request.*/
  1486. struct TUnitReply {
  1487. TNetbuf opt;
  1488. TNetbuf udata;
  1489. OTSequence sequence;
  1490. };
  1491. typedef struct TUnitReply TUnitReply;
  1492. /*
  1493. ***** Mapper Parameter Types *****
  1494. These structures are all used as parameters to the OT's
  1495. mapper routines.
  1496. */
  1497. /* TRegisterRequest holds the name to register in a call to OTRegisterName.*/
  1498. struct TRegisterRequest {
  1499. TNetbuf name;
  1500. TNetbuf addr;
  1501. OTFlags flags;
  1502. };
  1503. typedef struct TRegisterRequest TRegisterRequest;
  1504. /*
  1505. TRegisterReply returns information about the registered name in a call
  1506. to OTRegisterName.
  1507. */
  1508. struct TRegisterReply {
  1509. TNetbuf addr;
  1510. OTNameID nameid;
  1511. };
  1512. typedef struct TRegisterReply TRegisterReply;
  1513. /* TLookupRequest holds the name to look up in a call to OTLookupName.*/
  1514. struct TLookupRequest {
  1515. TNetbuf name;
  1516. TNetbuf addr;
  1517. UInt32 maxcnt;
  1518. OTTimeout timeout;
  1519. OTFlags flags;
  1520. };
  1521. typedef struct TLookupRequest TLookupRequest;
  1522. /*
  1523. TLookupReply returns information about the found names after a call
  1524. to OTLookupName.
  1525. */
  1526. struct TLookupReply {
  1527. TNetbuf names;
  1528. UInt32 rspcount;
  1529. };
  1530. typedef struct TLookupReply TLookupReply;
  1531. /*
  1532. TLookupBuffer describes the contents of the names buffer pointed
  1533. to by the TLookupReply.
  1534. */
  1535. struct TLookupBuffer {
  1536. UInt16 fAddressLength;
  1537. UInt16 fNameLength;
  1538. UInt8 fAddressBuffer[1];
  1539. };
  1540. typedef struct TLookupBuffer TLookupBuffer;
  1541. /*
  1542. OTNextLookupBuffer allows you to step through a packed array
  1543. of TLookupBuffers.
  1544. */
  1545. #define OTNextLookupBuffer(buf) \
  1546. ((TLookupBuffer*) \
  1547. ((char*)buf + ((OTOffsetOf(TLookupBuffer, fAddressBuffer) + buf->fAddressLength + buf->fNameLength + 3) & ~3)))
  1548. /* ***** Initializing and Shutting Down Open Transport ******/
  1549. #if !OTKERNEL
  1550. typedef struct OpaqueOTClientContextPtr* OTClientContextPtr;
  1551. /*
  1552. For Carbon the InitOpenTransport interface has changed so it takes a flags parameter
  1553. and returns a client context pointer.
  1554. The flag passed to indicates whether OT should be initialized for application use or for some other target
  1555. (for example, plugins that run in an application context but not the application itself.)
  1556. Applications that are not interested in the value of the client context pointer may pass NULL
  1557. as outClientContext -- they will pass NULL to other routines that take a OTClientContextPtr.
  1558. */
  1559. typedef UInt32 OTInitializationFlags;
  1560. enum {
  1561. kInitOTForApplicationMask = 1,
  1562. kInitOTForExtensionMask = 2
  1563. };
  1564. /*
  1565. * InitOpenTransportInContext()
  1566. *
  1567. * Availability:
  1568. * Non-Carbon CFM: not available
  1569. * CarbonLib: in CarbonLib 1.0 and later
  1570. * Mac OS X: in version 10.0 and later
  1571. */
  1572. EXTERN_API( OSStatus )
  1573. InitOpenTransportInContext(
  1574. OTInitializationFlags flags,
  1575. OTClientContextPtr * outClientContext); /* can be NULL */
  1576. /*
  1577. Under Carbon, CloseOpenTransport takes a client context pointer. Applications may pass NULL
  1578. after calling InitOpenTransport(kInitOTForApplicationMask, ...). Non-applications must always pass a
  1579. valid client context.
  1580. */
  1581. /*
  1582. * CloseOpenTransportInContext()
  1583. *
  1584. * Availability:
  1585. * Non-Carbon CFM: not available
  1586. * CarbonLib: in CarbonLib 1.0 and later
  1587. * Mac OS X: in version 10.0 and later
  1588. */
  1589. EXTERN_API( void )
  1590. CloseOpenTransportInContext(OTClientContextPtr clientContext);
  1591. #if CALL_NOT_IN_CARBON
  1592. /*
  1593. * InitOpenTransport()
  1594. *
  1595. * Availability:
  1596. * Non-Carbon CFM: not available
  1597. * CarbonLib: not available
  1598. * Mac OS X: not available
  1599. */
  1600. EXTERN_API( OSStatus )
  1601. InitOpenTransport(void);
  1602. /*
  1603. * InitOpenTransportUtilities()
  1604. *
  1605. * Availability:
  1606. * Non-Carbon CFM: not available
  1607. * CarbonLib: not available
  1608. * Mac OS X: not available
  1609. */
  1610. EXTERN_API( OSStatus )
  1611. InitOpenTransportUtilities(void);
  1612. /*
  1613. * CloseOpenTransport()
  1614. *
  1615. * Availability:
  1616. * Non-Carbon CFM: not available
  1617. * CarbonLib: not available
  1618. * Mac OS X: not available
  1619. */
  1620. EXTERN_API( void )
  1621. CloseOpenTransport(void);
  1622. /*
  1623. * OTRegisterAsClient()
  1624. *
  1625. * Availability:
  1626. * Non-Carbon CFM: not available
  1627. * CarbonLib: not available
  1628. * Mac OS X: not available
  1629. */
  1630. EXTERN_API( OSStatus )
  1631. OTRegisterAsClient(
  1632. OTClientName name,
  1633. OTNotifyUPP proc);
  1634. /*
  1635. This registers yourself as a client for any miscellaneous Open Transport
  1636. notifications that come along. CloseOpenTransport will automatically do
  1637. an OTUnregisterAsClient, if you have not already done so.
  1638. */
  1639. /*
  1640. * OTUnregisterAsClient()
  1641. *
  1642. * Availability:
  1643. * Non-Carbon CFM: not available
  1644. * CarbonLib: not available
  1645. * Mac OS X: not available
  1646. */
  1647. EXTERN_API( OSStatus )
  1648. OTUnregisterAsClient(void);
  1649. #endif /* CALL_NOT_IN_CARBON */
  1650. /*
  1651. * OTRegisterAsClientInContext()
  1652. *
  1653. * Availability:
  1654. * Non-Carbon CFM: not available
  1655. * CarbonLib: in CarbonLib 1.3 and later
  1656. * Mac OS X: in version 10.0 and later
  1657. */
  1658. EXTERN_API( OSStatus )
  1659. OTRegisterAsClientInContext(
  1660. OTClientName name,
  1661. OTNotifyUPP proc,
  1662. OTClientContextPtr clientContext); /* can be NULL */
  1663. /*
  1664. * OTUnregisterAsClientInContext()
  1665. *
  1666. * Availability:
  1667. * Non-Carbon CFM: not available
  1668. * CarbonLib: in CarbonLib 1.3 and later
  1669. * Mac OS X: in version 10.0 and later
  1670. */
  1671. EXTERN_API( OSStatus )
  1672. OTUnregisterAsClientInContext(OTClientContextPtr clientContext);
  1673. #if OTCARBONAPPLICATION
  1674. /* The following macro may be used by applications only.*/
  1675. #define InitOpenTransport() InitOpenTransportInContext(kInitOTForApplicationMask, NULL)
  1676. #define CloseOpenTransport() CloseOpenTransportInContext(NULL)
  1677. #define OTRegisterAsClient(name, proc) OTRegisterAsClientInContext(name, proc, NULL)
  1678. #define OTUnregisterAsClient() OTUnregisterAsClientInContext(NULL)
  1679. #endif /* OTCARBONAPPLICATION */
  1680. #endif /* !OTKERNEL */
  1681. /* ***** Tasking Model ******/
  1682. /*
  1683. OTEnterInterrupt/OTLeaveInterrupt are normally used within the kernel to
  1684. tell Open Transport we're at hardware interrupt time. Clients can also
  1685. them to do the same.
  1686. */
  1687. #if CALL_NOT_IN_CARBON
  1688. /*
  1689. * OTEnterInterrupt()
  1690. *
  1691. * Availability:
  1692. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  1693. * CarbonLib: not available
  1694. * Mac OS X: not available
  1695. */
  1696. EXTERN_API( void )
  1697. OTEnterInterrupt(void);
  1698. /*
  1699. * OTLeaveInterrupt()
  1700. *
  1701. * Availability:
  1702. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  1703. * CarbonLib: not available
  1704. * Mac OS X: not available
  1705. */
  1706. EXTERN_API( void )
  1707. OTLeaveInterrupt(void);
  1708. /*
  1709. * OTIsAtInterruptLevel()
  1710. *
  1711. * Availability:
  1712. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  1713. * CarbonLib: not available
  1714. * Mac OS X: not available
  1715. */
  1716. EXTERN_API_C( Boolean )
  1717. OTIsAtInterruptLevel(void);
  1718. /*
  1719. * OTCanLoadLibraries()
  1720. *
  1721. * Availability:
  1722. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  1723. * CarbonLib: not available
  1724. * Mac OS X: not available
  1725. */
  1726. EXTERN_API_C( Boolean )
  1727. OTCanLoadLibraries(void);
  1728. /*
  1729. All OT task callbacks use the same prototype, shown below.
  1730. This is only a UPP for CFM-68K clients.
  1731. */
  1732. #endif /* CALL_NOT_IN_CARBON */
  1733. typedef CALLBACK_API( void , OTProcessProcPtr )(void * arg);
  1734. typedef TVECTOR_UPP_TYPE(OTProcessProcPtr) OTProcessUPP;
  1735. /*
  1736. * NewOTProcessUPP()
  1737. *
  1738. * Availability:
  1739. * Non-Carbon CFM: available as macro/inline
  1740. * CarbonLib: in CarbonLib 1.0 and later
  1741. * Mac OS X: in version 10.0 and later
  1742. */
  1743. EXTERN_API_C( OTProcessUPP )
  1744. NewOTProcessUPP(OTProcessProcPtr userRoutine);
  1745. #if !OPAQUE_UPP_TYPES
  1746. enum { uppOTProcessProcInfo = 0x000000C0 }; /* pascal no_return_value Func(4_bytes) */
  1747. #ifdef __cplusplus
  1748. inline DEFINE_API_C(OTProcessUPP) NewOTProcessUPP(OTProcessProcPtr userRoutine) { return userRoutine; }
  1749. #else
  1750. #define NewOTProcessUPP(userRoutine) (userRoutine)
  1751. #endif
  1752. #endif
  1753. /*
  1754. * DisposeOTProcessUPP()
  1755. *
  1756. * Availability:
  1757. * Non-Carbon CFM: available as macro/inline
  1758. * CarbonLib: in CarbonLib 1.0 and later
  1759. * Mac OS X: in version 10.0 and later
  1760. */
  1761. EXTERN_API_C( void )
  1762. DisposeOTProcessUPP(OTProcessUPP userUPP);
  1763. #if !OPAQUE_UPP_TYPES
  1764. #ifdef __cplusplus
  1765. inline DEFINE_API_C(void) DisposeOTProcessUPP(OTProcessUPP) {}
  1766. #else
  1767. #define DisposeOTProcessUPP(userUPP)
  1768. #endif
  1769. #endif
  1770. /*
  1771. * InvokeOTProcessUPP()
  1772. *
  1773. * Availability:
  1774. * Non-Carbon CFM: available as macro/inline
  1775. * CarbonLib: in CarbonLib 1.0 and later
  1776. * Mac OS X: in version 10.0 and later
  1777. */
  1778. EXTERN_API_C( void )
  1779. InvokeOTProcessUPP(
  1780. void * arg,
  1781. OTProcessUPP userUPP);
  1782. #if !OPAQUE_UPP_TYPES
  1783. #ifdef __cplusplus
  1784. inline DEFINE_API_C(void) InvokeOTProcessUPP(void * arg, OTProcessUPP userUPP) { (*userUPP)(arg); }
  1785. #else
  1786. #define InvokeOTProcessUPP(arg, userUPP) (*userUPP)(arg)
  1787. #endif
  1788. #endif
  1789. #if !OTKERNEL
  1790. /*
  1791. Under Carbon, OTCreateDeferredTask takes a client context pointer. Applications may pass NULL
  1792. after calling InitOpenTransport(kInitOTForApplicationMask, ...). Non-applications must always pass a
  1793. valid client context.
  1794. */
  1795. /*
  1796. * OTCreateDeferredTaskInContext()
  1797. *
  1798. * Availability:
  1799. * Non-Carbon CFM: not available
  1800. * CarbonLib: in CarbonLib 1.0 and later
  1801. * Mac OS X: in version 10.0 and later
  1802. */
  1803. EXTERN_API( long )
  1804. OTCreateDeferredTaskInContext(
  1805. OTProcessUPP upp,
  1806. void * arg,
  1807. OTClientContextPtr clientContext); /* can be NULL */
  1808. #endif /* !OTKERNEL */
  1809. /*
  1810. OT deferred tasks are often more convenience that standard Mac OS
  1811. although they have no significant advantages beyond convenience.
  1812. */
  1813. typedef long OTDeferredTaskRef;
  1814. #if CALL_NOT_IN_CARBON
  1815. /*
  1816. * OTCreateDeferredTask()
  1817. *
  1818. * Availability:
  1819. * Non-Carbon CFM: not available
  1820. * CarbonLib: not available
  1821. * Mac OS X: not available
  1822. */
  1823. EXTERN_API( OTDeferredTaskRef )
  1824. OTCreateDeferredTask(
  1825. OTProcessUPP proc,
  1826. void * arg);
  1827. #endif /* CALL_NOT_IN_CARBON */
  1828. /*
  1829. * OTScheduleDeferredTask()
  1830. *
  1831. * Availability:
  1832. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  1833. * CarbonLib: in CarbonLib 1.0 and later
  1834. * Mac OS X: in version 10.0 and later
  1835. */
  1836. EXTERN_API( Boolean )
  1837. OTScheduleDeferredTask(OTDeferredTaskRef dtCookie);
  1838. #if CALL_NOT_IN_CARBON
  1839. /*
  1840. * OTScheduleInterruptTask()
  1841. *
  1842. * Availability:
  1843. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  1844. * CarbonLib: not available
  1845. * Mac OS X: not available
  1846. */
  1847. EXTERN_API( Boolean )
  1848. OTScheduleInterruptTask(OTDeferredTaskRef dtCookie);
  1849. #endif /* CALL_NOT_IN_CARBON */
  1850. /*
  1851. * OTDestroyDeferredTask()
  1852. *
  1853. * Availability:
  1854. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  1855. * CarbonLib: in CarbonLib 1.0 and later
  1856. * Mac OS X: in version 10.0 and later
  1857. */
  1858. EXTERN_API( OSStatus )
  1859. OTDestroyDeferredTask(OTDeferredTaskRef dtCookie);
  1860. #if OTCARBONAPPLICATION
  1861. /* The following macro may be used by applications only.*/
  1862. #define OTCreateDeferredTask(upp, arg) OTCreateDeferredTaskInContext(upp, arg, NULL)
  1863. #endif /* OTCARBONAPPLICATION */
  1864. #if !OTKERNEL
  1865. /*
  1866. OT system tasks allow you to schedule a procedure to be called
  1867. at system task time. Potentially useful, but it relies on someone
  1868. calling SystemTask (or WaitNextEvent, which calls SystemTask).
  1869. Not available to kernel code because relying on system task time
  1870. to make progress is likely to result in deadlocks.
  1871. */
  1872. typedef long OTSystemTaskRef;
  1873. #if CALL_NOT_IN_CARBON
  1874. /*
  1875. * OTCreateSystemTask()
  1876. *
  1877. * Availability:
  1878. * Non-Carbon CFM: not available
  1879. * CarbonLib: not available
  1880. * Mac OS X: not available
  1881. */
  1882. EXTERN_API( OTSystemTaskRef )
  1883. OTCreateSystemTask(
  1884. OTProcessUPP proc,
  1885. void * arg);
  1886. /*
  1887. * OTDestroySystemTask()
  1888. *
  1889. * Availability:
  1890. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  1891. * CarbonLib: not available
  1892. * Mac OS X: not available
  1893. */
  1894. EXTERN_API( OSStatus )
  1895. OTDestroySystemTask(OTSystemTaskRef stCookie);
  1896. /*
  1897. * OTScheduleSystemTask()
  1898. *
  1899. * Availability:
  1900. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  1901. * CarbonLib: not available
  1902. * Mac OS X: not available
  1903. */
  1904. EXTERN_API( Boolean )
  1905. OTScheduleSystemTask(OTSystemTaskRef stCookie);
  1906. /*
  1907. * OTCancelSystemTask()
  1908. *
  1909. * Availability:
  1910. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  1911. * CarbonLib: not available
  1912. * Mac OS X: not available
  1913. */
  1914. EXTERN_API( Boolean )
  1915. OTCancelSystemTask(OTSystemTaskRef stCookie);
  1916. #endif /* CALL_NOT_IN_CARBON */
  1917. /*
  1918. * OTCanMakeSyncCall()
  1919. *
  1920. * Availability:
  1921. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  1922. * CarbonLib: in CarbonLib 1.0 and later
  1923. * Mac OS X: in version 10.0 and later
  1924. */
  1925. EXTERN_API( Boolean )
  1926. OTCanMakeSyncCall(void);
  1927. #endif /* !OTKERNEL */
  1928. /* ***** Interface to Providers ******/
  1929. #if !OTKERNEL
  1930. #if CALL_NOT_IN_CARBON
  1931. /*
  1932. * OTAsyncOpenProvider()
  1933. *
  1934. * Availability:
  1935. * Non-Carbon CFM: not available
  1936. * CarbonLib: not available
  1937. * Mac OS X: not available
  1938. */
  1939. EXTERN_API( OSStatus )
  1940. OTAsyncOpenProvider(
  1941. OTConfigurationRef cfig,
  1942. OTOpenFlags flags,
  1943. OTNotifyUPP proc,
  1944. void * contextPtr);
  1945. /*
  1946. * OTOpenProvider()
  1947. *
  1948. * Availability:
  1949. * Non-Carbon CFM: not available
  1950. * CarbonLib: not available
  1951. * Mac OS X: not available
  1952. */
  1953. EXTERN_API( ProviderRef )
  1954. OTOpenProvider(
  1955. OTConfigurationRef cfig,
  1956. OTOpenFlags flags,
  1957. OSStatus * errPtr);
  1958. #endif /* CALL_NOT_IN_CARBON */
  1959. /*
  1960. * OTCloseProvider()
  1961. *
  1962. * Availability:
  1963. * Non-Carbon CFM: not available
  1964. * CarbonLib: in CarbonLib 1.0 and later
  1965. * Mac OS X: in version 10.0 and later
  1966. */
  1967. EXTERN_API( OSStatus )
  1968. OTCloseProvider(ProviderRef ref);
  1969. #if CALL_NOT_IN_CARBON
  1970. /*
  1971. * OTTransferProviderOwnership()
  1972. *
  1973. * Availability:
  1974. * Non-Carbon CFM: not available
  1975. * CarbonLib: not available
  1976. * Mac OS X: not available
  1977. */
  1978. EXTERN_API( ProviderRef )
  1979. OTTransferProviderOwnership(
  1980. ProviderRef ref,
  1981. OTClient prevOwner,
  1982. OSStatus * errPtr);
  1983. /*
  1984. * OTWhoAmI()
  1985. *
  1986. * Availability:
  1987. * Non-Carbon CFM: not available
  1988. * CarbonLib: not available
  1989. * Mac OS X: not available
  1990. */
  1991. EXTERN_API( OTClient )
  1992. OTWhoAmI(void);
  1993. /*
  1994. * OTGetProviderPortRef()
  1995. *
  1996. * Availability:
  1997. * Non-Carbon CFM: in OTClientLib 1.0 and later
  1998. * CarbonLib: not available
  1999. * Mac OS X: not available
  2000. */
  2001. EXTERN_API( OTPortRef )
  2002. OTGetProviderPortRef(ProviderRef ref);
  2003. #endif /* CALL_NOT_IN_CARBON */
  2004. /*
  2005. * OTIoctl()
  2006. *
  2007. * Availability:
  2008. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2009. * CarbonLib: in CarbonLib 1.0 and later
  2010. * Mac OS X: in version 10.0 and later
  2011. */
  2012. EXTERN_API( SInt32 )
  2013. OTIoctl(
  2014. ProviderRef ref,
  2015. UInt32 cmd,
  2016. void * data);
  2017. #if CALL_NOT_IN_CARBON
  2018. /*
  2019. * OTGetMessage()
  2020. *
  2021. * Availability:
  2022. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2023. * CarbonLib: not available
  2024. * Mac OS X: not available
  2025. */
  2026. EXTERN_API( OTResult )
  2027. OTGetMessage(
  2028. ProviderRef ref,
  2029. strbuf * ctlbuf,
  2030. strbuf * databuf,
  2031. OTFlags * flagsPtr);
  2032. /*
  2033. * OTGetPriorityMessage()
  2034. *
  2035. * Availability:
  2036. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2037. * CarbonLib: not available
  2038. * Mac OS X: not available
  2039. */
  2040. EXTERN_API( OTResult )
  2041. OTGetPriorityMessage(
  2042. ProviderRef ref,
  2043. strbuf * ctlbuf,
  2044. strbuf * databuf,
  2045. OTBand * bandPtr,
  2046. OTFlags * flagsPtr);
  2047. /*
  2048. * OTPutMessage()
  2049. *
  2050. * Availability:
  2051. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2052. * CarbonLib: not available
  2053. * Mac OS X: not available
  2054. */
  2055. EXTERN_API( OSStatus )
  2056. OTPutMessage(
  2057. ProviderRef ref,
  2058. const strbuf * ctlbuf,
  2059. const strbuf * databuf,
  2060. OTFlags flags);
  2061. /*
  2062. * OTPutPriorityMessage()
  2063. *
  2064. * Availability:
  2065. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2066. * CarbonLib: not available
  2067. * Mac OS X: not available
  2068. */
  2069. EXTERN_API( OSStatus )
  2070. OTPutPriorityMessage(
  2071. ProviderRef ref,
  2072. const strbuf * ctlbuf,
  2073. const strbuf * databuf,
  2074. OTBand band,
  2075. OTFlags flags);
  2076. #endif /* CALL_NOT_IN_CARBON */
  2077. /*
  2078. * OTSetAsynchronous()
  2079. *
  2080. * Availability:
  2081. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2082. * CarbonLib: in CarbonLib 1.0 and later
  2083. * Mac OS X: in version 10.0 and later
  2084. */
  2085. EXTERN_API( OSStatus )
  2086. OTSetAsynchronous(ProviderRef ref);
  2087. /*
  2088. * OTSetSynchronous()
  2089. *
  2090. * Availability:
  2091. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2092. * CarbonLib: in CarbonLib 1.0 and later
  2093. * Mac OS X: in version 10.0 and later
  2094. */
  2095. EXTERN_API( OSStatus )
  2096. OTSetSynchronous(ProviderRef ref);
  2097. /*
  2098. * OTIsSynchronous()
  2099. *
  2100. * Availability:
  2101. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2102. * CarbonLib: in CarbonLib 1.0 and later
  2103. * Mac OS X: in version 10.0 and later
  2104. */
  2105. EXTERN_API( Boolean )
  2106. OTIsSynchronous(ProviderRef ref);
  2107. /*
  2108. * OTSetBlocking()
  2109. *
  2110. * Availability:
  2111. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2112. * CarbonLib: in CarbonLib 1.0 and later
  2113. * Mac OS X: in version 10.0 and later
  2114. */
  2115. EXTERN_API( OSStatus )
  2116. OTSetBlocking(ProviderRef ref);
  2117. /*
  2118. * OTSetNonBlocking()
  2119. *
  2120. * Availability:
  2121. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2122. * CarbonLib: in CarbonLib 1.0 and later
  2123. * Mac OS X: in version 10.0 and later
  2124. */
  2125. EXTERN_API( OSStatus )
  2126. OTSetNonBlocking(ProviderRef ref);
  2127. /*
  2128. * OTIsBlocking()
  2129. *
  2130. * Availability:
  2131. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2132. * CarbonLib: in CarbonLib 1.0 and later
  2133. * Mac OS X: in version 10.0 and later
  2134. */
  2135. EXTERN_API( Boolean )
  2136. OTIsBlocking(ProviderRef ref);
  2137. /*
  2138. * OTInstallNotifier()
  2139. *
  2140. * Availability:
  2141. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2142. * CarbonLib: in CarbonLib 1.0 and later
  2143. * Mac OS X: in version 10.0 and later
  2144. */
  2145. EXTERN_API( OSStatus )
  2146. OTInstallNotifier(
  2147. ProviderRef ref,
  2148. OTNotifyUPP proc,
  2149. void * contextPtr);
  2150. /*
  2151. * OTUseSyncIdleEvents()
  2152. *
  2153. * Availability:
  2154. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2155. * CarbonLib: in CarbonLib 1.0 and later
  2156. * Mac OS X: in version 10.0 and later
  2157. */
  2158. EXTERN_API( OSStatus )
  2159. OTUseSyncIdleEvents(
  2160. ProviderRef ref,
  2161. Boolean useEvents);
  2162. /*
  2163. * OTRemoveNotifier()
  2164. *
  2165. * Availability:
  2166. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2167. * CarbonLib: in CarbonLib 1.0 and later
  2168. * Mac OS X: in version 10.0 and later
  2169. */
  2170. EXTERN_API( void )
  2171. OTRemoveNotifier(ProviderRef ref);
  2172. /*
  2173. * OTLeaveNotifier()
  2174. *
  2175. * Availability:
  2176. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2177. * CarbonLib: in CarbonLib 1.0 and later
  2178. * Mac OS X: in version 10.0 and later
  2179. */
  2180. EXTERN_API( void )
  2181. OTLeaveNotifier(ProviderRef ref);
  2182. /*
  2183. * OTEnterNotifier()
  2184. *
  2185. * Availability:
  2186. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2187. * CarbonLib: in CarbonLib 1.0 and later
  2188. * Mac OS X: in version 10.0 and later
  2189. */
  2190. EXTERN_API( Boolean )
  2191. OTEnterNotifier(ProviderRef ref);
  2192. /*
  2193. * OTAckSends()
  2194. *
  2195. * Availability:
  2196. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2197. * CarbonLib: in CarbonLib 1.0 and later
  2198. * Mac OS X: in version 10.0 and later
  2199. */
  2200. EXTERN_API( OSStatus )
  2201. OTAckSends(ProviderRef ref);
  2202. /*
  2203. * OTDontAckSends()
  2204. *
  2205. * Availability:
  2206. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2207. * CarbonLib: in CarbonLib 1.0 and later
  2208. * Mac OS X: in version 10.0 and later
  2209. */
  2210. EXTERN_API( OSStatus )
  2211. OTDontAckSends(ProviderRef ref);
  2212. /*
  2213. * OTIsAckingSends()
  2214. *
  2215. * Availability:
  2216. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2217. * CarbonLib: in CarbonLib 1.0 and later
  2218. * Mac OS X: in version 10.0 and later
  2219. */
  2220. EXTERN_API( Boolean )
  2221. OTIsAckingSends(ProviderRef ref);
  2222. /*
  2223. * OTCancelSynchronousCalls()
  2224. *
  2225. * Availability:
  2226. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2227. * CarbonLib: in CarbonLib 1.0 and later
  2228. * Mac OS X: in version 10.0 and later
  2229. */
  2230. EXTERN_API( OSStatus )
  2231. OTCancelSynchronousCalls(
  2232. ProviderRef ref,
  2233. OSStatus err);
  2234. #define OTIsNonBlocking(ref) (!OTIsBlocking(ref))
  2235. #define OTIsAsynchronous(ref) (!OTIsSynchronous(ref))
  2236. #endif /* !OTKERNEL */
  2237. /* ***** Interface to Endpoints ******/
  2238. #if !OTKERNEL
  2239. /* Open/Close*/
  2240. /*
  2241. Under Carbon, the OpenEndpoint routines take a client context pointer. Applications may pass NULL after
  2242. calling InitOpenTransport(kInitOTForApplicationMask, ...). Non-applications must always pass a
  2243. valid client context.
  2244. */
  2245. /*
  2246. * OTOpenEndpointInContext()
  2247. *
  2248. * Availability:
  2249. * Non-Carbon CFM: not available
  2250. * CarbonLib: in CarbonLib 1.0 and later
  2251. * Mac OS X: in version 10.0 and later
  2252. */
  2253. EXTERN_API( EndpointRef )
  2254. OTOpenEndpointInContext(
  2255. OTConfigurationRef config,
  2256. OTOpenFlags oflag,
  2257. TEndpointInfo * info, /* can be NULL */
  2258. OSStatus * err,
  2259. OTClientContextPtr clientContext); /* can be NULL */
  2260. /*
  2261. * OTAsyncOpenEndpointInContext()
  2262. *
  2263. * Availability:
  2264. * Non-Carbon CFM: not available
  2265. * CarbonLib: in CarbonLib 1.0 and later
  2266. * Mac OS X: in version 10.0 and later
  2267. */
  2268. EXTERN_API( OSStatus )
  2269. OTAsyncOpenEndpointInContext(
  2270. OTConfigurationRef config,
  2271. OTOpenFlags oflag,
  2272. TEndpointInfo * info, /* can be NULL */
  2273. OTNotifyUPP upp,
  2274. void * contextPtr,
  2275. OTClientContextPtr clientContext); /* can be NULL */
  2276. #if CALL_NOT_IN_CARBON
  2277. /*
  2278. * OTOpenEndpoint()
  2279. *
  2280. * Availability:
  2281. * Non-Carbon CFM: not available
  2282. * CarbonLib: not available
  2283. * Mac OS X: not available
  2284. */
  2285. EXTERN_API( EndpointRef )
  2286. OTOpenEndpoint(
  2287. OTConfigurationRef cfig,
  2288. OTOpenFlags oflag,
  2289. TEndpointInfo * info, /* can be NULL */
  2290. OSStatus * err);
  2291. /*
  2292. * OTAsyncOpenEndpoint()
  2293. *
  2294. * Availability:
  2295. * Non-Carbon CFM: not available
  2296. * CarbonLib: not available
  2297. * Mac OS X: not available
  2298. */
  2299. EXTERN_API( OSStatus )
  2300. OTAsyncOpenEndpoint(
  2301. OTConfigurationRef cfig,
  2302. OTOpenFlags oflag,
  2303. TEndpointInfo * info, /* can be NULL */
  2304. OTNotifyUPP proc,
  2305. void * contextPtr);
  2306. #endif /* CALL_NOT_IN_CARBON */
  2307. #if OTCARBONAPPLICATION
  2308. /* The following macros may be used by applications only.*/
  2309. #define OTOpenEndpoint(config, oflag, info, err) OTOpenEndpointInContext(config, oflag, info, err, NULL)
  2310. #define OTAsyncOpenEndpoint(config, oflag, info, proc, contextPtr) OTAsyncOpenEndpointInContext(config, oflag, info, proc, contextPtr, NULL)
  2311. #endif /* OTCARBONAPPLICATION */
  2312. /* Misc Information*/
  2313. /*
  2314. * OTGetEndpointInfo()
  2315. *
  2316. * Availability:
  2317. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2318. * CarbonLib: in CarbonLib 1.0 and later
  2319. * Mac OS X: in version 10.0 and later
  2320. */
  2321. EXTERN_API( OSStatus )
  2322. OTGetEndpointInfo(
  2323. EndpointRef ref,
  2324. TEndpointInfo * info);
  2325. /*
  2326. * OTGetEndpointState()
  2327. *
  2328. * Availability:
  2329. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2330. * CarbonLib: in CarbonLib 1.0 and later
  2331. * Mac OS X: in version 10.0 and later
  2332. */
  2333. EXTERN_API( OTResult )
  2334. OTGetEndpointState(EndpointRef ref);
  2335. /*
  2336. * OTLook()
  2337. *
  2338. * Availability:
  2339. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2340. * CarbonLib: in CarbonLib 1.0 and later
  2341. * Mac OS X: in version 10.0 and later
  2342. */
  2343. EXTERN_API( OTResult )
  2344. OTLook(EndpointRef ref);
  2345. #if CALL_NOT_IN_CARBON
  2346. /*
  2347. * OTSync()
  2348. *
  2349. * Availability:
  2350. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2351. * CarbonLib: not available
  2352. * Mac OS X: not available
  2353. */
  2354. EXTERN_API( OTResult )
  2355. OTSync(EndpointRef ref);
  2356. #endif /* CALL_NOT_IN_CARBON */
  2357. /*
  2358. * OTCountDataBytes()
  2359. *
  2360. * Availability:
  2361. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2362. * CarbonLib: in CarbonLib 1.0 and later
  2363. * Mac OS X: in version 10.0 and later
  2364. */
  2365. EXTERN_API( OTResult )
  2366. OTCountDataBytes(
  2367. EndpointRef ref,
  2368. OTByteCount * countPtr);
  2369. /*
  2370. * OTGetProtAddress()
  2371. *
  2372. * Availability:
  2373. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2374. * CarbonLib: in CarbonLib 1.0 and later
  2375. * Mac OS X: in version 10.0 and later
  2376. */
  2377. EXTERN_API( OSStatus )
  2378. OTGetProtAddress(
  2379. EndpointRef ref,
  2380. TBind * boundAddr, /* can be NULL */
  2381. TBind * peerAddr); /* can be NULL */
  2382. /*
  2383. * OTResolveAddress()
  2384. *
  2385. * Availability:
  2386. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2387. * CarbonLib: in CarbonLib 1.0 and later
  2388. * Mac OS X: in version 10.0 and later
  2389. */
  2390. EXTERN_API( OSStatus )
  2391. OTResolveAddress(
  2392. EndpointRef ref,
  2393. TBind * reqAddr,
  2394. TBind * retAddr,
  2395. OTTimeout timeOut);
  2396. /* Allocating structures*/
  2397. /*
  2398. Note:
  2399. In general, Apple recommends that you avoid the OTAlloc call because
  2400. using it extensively causes your program to allocate and deallocate
  2401. many memory blocks, with each extra memory allocation costing time.
  2402. */
  2403. /*
  2404. Under Carbon, OTAlloc takes a client context pointer. Applications may pass NULL after
  2405. calling InitOpenTransport(kInitOTForApplicationMask, ...). Non-applications must always pass a
  2406. valid client context.
  2407. */
  2408. /*
  2409. * OTAllocInContext()
  2410. *
  2411. * Availability:
  2412. * Non-Carbon CFM: not available
  2413. * CarbonLib: in CarbonLib 1.0 and later
  2414. * Mac OS X: in version 10.0 and later
  2415. */
  2416. EXTERN_API( void * )
  2417. OTAllocInContext(
  2418. EndpointRef ref,
  2419. OTStructType structType,
  2420. UInt32 fields,
  2421. OSStatus * err,
  2422. OTClientContextPtr clientContext); /* can be NULL */
  2423. #if CALL_NOT_IN_CARBON
  2424. /*
  2425. * OTAlloc()
  2426. *
  2427. * Availability:
  2428. * Non-Carbon CFM: not available
  2429. * CarbonLib: not available
  2430. * Mac OS X: not available
  2431. */
  2432. EXTERN_API( void * )
  2433. OTAlloc(
  2434. EndpointRef ref,
  2435. OTStructType structType,
  2436. OTFieldsType fields,
  2437. OSStatus * err);
  2438. #endif /* CALL_NOT_IN_CARBON */
  2439. #if OTCARBONAPPLICATION
  2440. /* The following macro may be used by applications only.*/
  2441. #define OTAlloc(ref, structType, fields, err) OTAllocInContext(ref, structType, fields, err, NULL)
  2442. #endif /* OTCARBONAPPLICATION */
  2443. /*
  2444. * OTFree()
  2445. *
  2446. * Availability:
  2447. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2448. * CarbonLib: in CarbonLib 1.0 and later
  2449. * Mac OS X: in version 10.0 and later
  2450. */
  2451. EXTERN_API( OTResult )
  2452. OTFree(
  2453. void * ptr,
  2454. OTStructType structType);
  2455. /* Option management*/
  2456. /* It looks simple enough...*/
  2457. /*
  2458. * OTOptionManagement()
  2459. *
  2460. * Availability:
  2461. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2462. * CarbonLib: in CarbonLib 1.0 and later
  2463. * Mac OS X: in version 10.0 and later
  2464. */
  2465. EXTERN_API( OSStatus )
  2466. OTOptionManagement(
  2467. EndpointRef ref,
  2468. TOptMgmt * req,
  2469. TOptMgmt * ret);
  2470. /* ... but then the hidden complexity emerges.*/
  2471. #if CALL_NOT_IN_CARBON
  2472. /*
  2473. * OTCreateOptions()
  2474. *
  2475. * Availability:
  2476. * Non-Carbon CFM: in OTClientUtilLib 1.0 and later
  2477. * CarbonLib: not available
  2478. * Mac OS X: not available
  2479. */
  2480. EXTERN_API( OSStatus )
  2481. OTCreateOptions(
  2482. const char * endPtName,
  2483. char ** strPtr,
  2484. TNetbuf * buf);
  2485. /*
  2486. * OTCreateOptionString()
  2487. *
  2488. * Availability:
  2489. * Non-Carbon CFM: in OTClientUtilLib 1.0 and later
  2490. * CarbonLib: not available
  2491. * Mac OS X: not available
  2492. */
  2493. EXTERN_API( OSStatus )
  2494. OTCreateOptionString(
  2495. const char * endPtName,
  2496. TOption ** opt,
  2497. void * bufEnd,
  2498. char * str,
  2499. OTByteCount stringSize);
  2500. #endif /* CALL_NOT_IN_CARBON */
  2501. /*
  2502. * OTNextOption()
  2503. *
  2504. * Availability:
  2505. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2506. * CarbonLib: in CarbonLib 1.0 and later
  2507. * Mac OS X: in version 10.0 and later
  2508. */
  2509. EXTERN_API( OSStatus )
  2510. OTNextOption(
  2511. UInt8 * buffer,
  2512. UInt32 buflen,
  2513. TOption ** prevOptPtr);
  2514. /*
  2515. * OTFindOption()
  2516. *
  2517. * Availability:
  2518. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2519. * CarbonLib: in CarbonLib 1.0 and later
  2520. * Mac OS X: in version 10.0 and later
  2521. */
  2522. EXTERN_API( TOption * )
  2523. OTFindOption(
  2524. UInt8 * buffer,
  2525. UInt32 buflen,
  2526. OTXTILevel level,
  2527. OTXTIName name);
  2528. /* Bind/Unbind*/
  2529. /*
  2530. * OTBind()
  2531. *
  2532. * Availability:
  2533. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2534. * CarbonLib: in CarbonLib 1.0 and later
  2535. * Mac OS X: in version 10.0 and later
  2536. */
  2537. EXTERN_API( OSStatus )
  2538. OTBind(
  2539. EndpointRef ref,
  2540. TBind * reqAddr, /* can be NULL */
  2541. TBind * retAddr); /* can be NULL */
  2542. /*
  2543. * OTUnbind()
  2544. *
  2545. * Availability:
  2546. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2547. * CarbonLib: in CarbonLib 1.0 and later
  2548. * Mac OS X: in version 10.0 and later
  2549. */
  2550. EXTERN_API( OSStatus )
  2551. OTUnbind(EndpointRef ref);
  2552. /* Connection creation/tear-down*/
  2553. /*
  2554. * OTConnect()
  2555. *
  2556. * Availability:
  2557. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2558. * CarbonLib: in CarbonLib 1.0 and later
  2559. * Mac OS X: in version 10.0 and later
  2560. */
  2561. EXTERN_API( OSStatus )
  2562. OTConnect(
  2563. EndpointRef ref,
  2564. TCall * sndCall,
  2565. TCall * rcvCall); /* can be NULL */
  2566. /*
  2567. * OTRcvConnect()
  2568. *
  2569. * Availability:
  2570. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2571. * CarbonLib: in CarbonLib 1.0 and later
  2572. * Mac OS X: in version 10.0 and later
  2573. */
  2574. EXTERN_API( OSStatus )
  2575. OTRcvConnect(
  2576. EndpointRef ref,
  2577. TCall * call); /* can be NULL */
  2578. /*
  2579. * OTListen()
  2580. *
  2581. * Availability:
  2582. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2583. * CarbonLib: in CarbonLib 1.0 and later
  2584. * Mac OS X: in version 10.0 and later
  2585. */
  2586. EXTERN_API( OSStatus )
  2587. OTListen(
  2588. EndpointRef ref,
  2589. TCall * call);
  2590. /*
  2591. * OTAccept()
  2592. *
  2593. * Availability:
  2594. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2595. * CarbonLib: in CarbonLib 1.0 and later
  2596. * Mac OS X: in version 10.0 and later
  2597. */
  2598. EXTERN_API( OSStatus )
  2599. OTAccept(
  2600. EndpointRef listener,
  2601. EndpointRef worker,
  2602. TCall * call);
  2603. /*
  2604. * OTSndDisconnect()
  2605. *
  2606. * Availability:
  2607. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2608. * CarbonLib: in CarbonLib 1.0 and later
  2609. * Mac OS X: in version 10.0 and later
  2610. */
  2611. EXTERN_API( OSStatus )
  2612. OTSndDisconnect(
  2613. EndpointRef ref,
  2614. TCall * call); /* can be NULL */
  2615. /*
  2616. * OTSndOrderlyDisconnect()
  2617. *
  2618. * Availability:
  2619. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2620. * CarbonLib: in CarbonLib 1.0 and later
  2621. * Mac OS X: in version 10.0 and later
  2622. */
  2623. EXTERN_API( OSStatus )
  2624. OTSndOrderlyDisconnect(EndpointRef ref);
  2625. /*
  2626. * OTRcvDisconnect()
  2627. *
  2628. * Availability:
  2629. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2630. * CarbonLib: in CarbonLib 1.0 and later
  2631. * Mac OS X: in version 10.0 and later
  2632. */
  2633. EXTERN_API( OSStatus )
  2634. OTRcvDisconnect(
  2635. EndpointRef ref,
  2636. TDiscon * discon); /* can be NULL */
  2637. /*
  2638. * OTRcvOrderlyDisconnect()
  2639. *
  2640. * Availability:
  2641. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2642. * CarbonLib: in CarbonLib 1.0 and later
  2643. * Mac OS X: in version 10.0 and later
  2644. */
  2645. EXTERN_API( OSStatus )
  2646. OTRcvOrderlyDisconnect(EndpointRef ref);
  2647. /* Connection-oriented send/receive*/
  2648. /*
  2649. * OTRcv()
  2650. *
  2651. * Availability:
  2652. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2653. * CarbonLib: in CarbonLib 1.0 and later
  2654. * Mac OS X: in version 10.0 and later
  2655. */
  2656. EXTERN_API( OTResult )
  2657. OTRcv(
  2658. EndpointRef ref,
  2659. void * buf,
  2660. OTByteCount nbytes,
  2661. OTFlags * flags);
  2662. /*
  2663. * OTSnd()
  2664. *
  2665. * Availability:
  2666. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2667. * CarbonLib: in CarbonLib 1.0 and later
  2668. * Mac OS X: in version 10.0 and later
  2669. */
  2670. EXTERN_API( OTResult )
  2671. OTSnd(
  2672. EndpointRef ref,
  2673. void * buf,
  2674. OTByteCount nbytes,
  2675. OTFlags flags);
  2676. /* Connectionless send/receive*/
  2677. /*
  2678. * OTSndUData()
  2679. *
  2680. * Availability:
  2681. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2682. * CarbonLib: in CarbonLib 1.0 and later
  2683. * Mac OS X: in version 10.0 and later
  2684. */
  2685. EXTERN_API( OSStatus )
  2686. OTSndUData(
  2687. EndpointRef ref,
  2688. TUnitData * udata);
  2689. /*
  2690. * OTRcvUData()
  2691. *
  2692. * Availability:
  2693. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2694. * CarbonLib: in CarbonLib 1.0 and later
  2695. * Mac OS X: in version 10.0 and later
  2696. */
  2697. EXTERN_API( OSStatus )
  2698. OTRcvUData(
  2699. EndpointRef ref,
  2700. TUnitData * udata,
  2701. OTFlags * flags);
  2702. /*
  2703. * OTRcvUDErr()
  2704. *
  2705. * Availability:
  2706. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2707. * CarbonLib: in CarbonLib 1.0 and later
  2708. * Mac OS X: in version 10.0 and later
  2709. */
  2710. EXTERN_API( OSStatus )
  2711. OTRcvUDErr(
  2712. EndpointRef ref,
  2713. TUDErr * uderr); /* can be NULL */
  2714. /* Connection-oriented transactions*/
  2715. #if CALL_NOT_IN_CARBON
  2716. /*
  2717. * OTSndRequest()
  2718. *
  2719. * Availability:
  2720. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2721. * CarbonLib: not available
  2722. * Mac OS X: not available
  2723. */
  2724. EXTERN_API( OSStatus )
  2725. OTSndRequest(
  2726. EndpointRef ref,
  2727. TRequest * req,
  2728. OTFlags reqFlags);
  2729. /*
  2730. * OTRcvReply()
  2731. *
  2732. * Availability:
  2733. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2734. * CarbonLib: not available
  2735. * Mac OS X: not available
  2736. */
  2737. EXTERN_API( OSStatus )
  2738. OTRcvReply(
  2739. EndpointRef ref,
  2740. TReply * reply,
  2741. OTFlags * replyFlags);
  2742. /*
  2743. * OTSndReply()
  2744. *
  2745. * Availability:
  2746. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2747. * CarbonLib: not available
  2748. * Mac OS X: not available
  2749. */
  2750. EXTERN_API( OSStatus )
  2751. OTSndReply(
  2752. EndpointRef ref,
  2753. TReply * reply,
  2754. OTFlags replyFlags);
  2755. /*
  2756. * OTRcvRequest()
  2757. *
  2758. * Availability:
  2759. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2760. * CarbonLib: not available
  2761. * Mac OS X: not available
  2762. */
  2763. EXTERN_API( OSStatus )
  2764. OTRcvRequest(
  2765. EndpointRef ref,
  2766. TRequest * req,
  2767. OTFlags * reqFlags);
  2768. /*
  2769. * OTCancelRequest()
  2770. *
  2771. * Availability:
  2772. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2773. * CarbonLib: not available
  2774. * Mac OS X: not available
  2775. */
  2776. EXTERN_API( OSStatus )
  2777. OTCancelRequest(
  2778. EndpointRef ref,
  2779. OTSequence sequence);
  2780. /*
  2781. * OTCancelReply()
  2782. *
  2783. * Availability:
  2784. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2785. * CarbonLib: not available
  2786. * Mac OS X: not available
  2787. */
  2788. EXTERN_API( OSStatus )
  2789. OTCancelReply(
  2790. EndpointRef ref,
  2791. OTSequence sequence);
  2792. /* Connectionless transactions*/
  2793. /*
  2794. * OTSndURequest()
  2795. *
  2796. * Availability:
  2797. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2798. * CarbonLib: not available
  2799. * Mac OS X: not available
  2800. */
  2801. EXTERN_API( OSStatus )
  2802. OTSndURequest(
  2803. EndpointRef ref,
  2804. TUnitRequest * req,
  2805. OTFlags reqFlags);
  2806. /*
  2807. * OTRcvUReply()
  2808. *
  2809. * Availability:
  2810. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2811. * CarbonLib: not available
  2812. * Mac OS X: not available
  2813. */
  2814. EXTERN_API( OSStatus )
  2815. OTRcvUReply(
  2816. EndpointRef ref,
  2817. TUnitReply * reply,
  2818. OTFlags * replyFlags);
  2819. /*
  2820. * OTSndUReply()
  2821. *
  2822. * Availability:
  2823. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2824. * CarbonLib: not available
  2825. * Mac OS X: not available
  2826. */
  2827. EXTERN_API( OSStatus )
  2828. OTSndUReply(
  2829. EndpointRef ref,
  2830. TUnitReply * reply,
  2831. OTFlags replyFlags);
  2832. /*
  2833. * OTRcvURequest()
  2834. *
  2835. * Availability:
  2836. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2837. * CarbonLib: not available
  2838. * Mac OS X: not available
  2839. */
  2840. EXTERN_API( OSStatus )
  2841. OTRcvURequest(
  2842. EndpointRef ref,
  2843. TUnitRequest * req,
  2844. OTFlags * reqFlags);
  2845. /*
  2846. * OTCancelURequest()
  2847. *
  2848. * Availability:
  2849. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2850. * CarbonLib: not available
  2851. * Mac OS X: not available
  2852. */
  2853. EXTERN_API( OSStatus )
  2854. OTCancelURequest(
  2855. EndpointRef ref,
  2856. OTSequence seq);
  2857. /*
  2858. * OTCancelUReply()
  2859. *
  2860. * Availability:
  2861. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2862. * CarbonLib: not available
  2863. * Mac OS X: not available
  2864. */
  2865. EXTERN_API( OSStatus )
  2866. OTCancelUReply(
  2867. EndpointRef ref,
  2868. OTSequence seq);
  2869. /* Interface to Mappers*/
  2870. /*
  2871. Under Carbon, the OpenMapper routines take a client context pointer. Applications may pass NULL after
  2872. calling InitOpenTransport(kInitOTForApplicationMask, ...). Non-applications must always pass a
  2873. valid client context.
  2874. */
  2875. #endif /* CALL_NOT_IN_CARBON */
  2876. /*
  2877. * OTAsyncOpenMapperInContext()
  2878. *
  2879. * Availability:
  2880. * Non-Carbon CFM: not available
  2881. * CarbonLib: in CarbonLib 1.0 and later
  2882. * Mac OS X: in version 10.0 and later
  2883. */
  2884. EXTERN_API( OSStatus )
  2885. OTAsyncOpenMapperInContext(
  2886. OTConfigurationRef config,
  2887. OTOpenFlags oflag,
  2888. OTNotifyUPP upp,
  2889. void * contextPtr,
  2890. OTClientContextPtr clientContext); /* can be NULL */
  2891. /*
  2892. * OTOpenMapperInContext()
  2893. *
  2894. * Availability:
  2895. * Non-Carbon CFM: not available
  2896. * CarbonLib: in CarbonLib 1.0 and later
  2897. * Mac OS X: in version 10.0 and later
  2898. */
  2899. EXTERN_API( MapperRef )
  2900. OTOpenMapperInContext(
  2901. OTConfigurationRef config,
  2902. OTOpenFlags oflag,
  2903. OSStatus * err,
  2904. OTClientContextPtr clientContext); /* can be NULL */
  2905. #if CALL_NOT_IN_CARBON
  2906. /*
  2907. * OTAsyncOpenMapper()
  2908. *
  2909. * Availability:
  2910. * Non-Carbon CFM: not available
  2911. * CarbonLib: not available
  2912. * Mac OS X: not available
  2913. */
  2914. EXTERN_API( OSStatus )
  2915. OTAsyncOpenMapper(
  2916. OTConfigurationRef cfig,
  2917. OTOpenFlags oflag,
  2918. OTNotifyUPP proc,
  2919. void * contextPtr);
  2920. /*
  2921. * OTOpenMapper()
  2922. *
  2923. * Availability:
  2924. * Non-Carbon CFM: not available
  2925. * CarbonLib: not available
  2926. * Mac OS X: not available
  2927. */
  2928. EXTERN_API( MapperRef )
  2929. OTOpenMapper(
  2930. OTConfigurationRef cfig,
  2931. OTOpenFlags oflag,
  2932. OSStatus * err);
  2933. #endif /* CALL_NOT_IN_CARBON */
  2934. #if OTCARBONAPPLICATION
  2935. /* The following macros may be used by applications only.*/
  2936. #define OTAsyncOpenMapper(config, oflag, proc, contextPtr) OTAsyncOpenMapperInContext(config, oflag, proc, contextPtr, NULL)
  2937. #define OTOpenMapper(config, oflag, err) OTOpenMapperInContext(config, oflag, err, NULL)
  2938. #endif /* OTCARBONAPPLICATION */
  2939. /*
  2940. * OTRegisterName()
  2941. *
  2942. * Availability:
  2943. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2944. * CarbonLib: in CarbonLib 1.0 and later
  2945. * Mac OS X: in version 10.0 and later
  2946. */
  2947. EXTERN_API( OSStatus )
  2948. OTRegisterName(
  2949. MapperRef ref,
  2950. TRegisterRequest * req,
  2951. TRegisterReply * reply);
  2952. /*
  2953. * OTDeleteName()
  2954. *
  2955. * Availability:
  2956. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2957. * CarbonLib: in CarbonLib 1.0 and later
  2958. * Mac OS X: in version 10.0 and later
  2959. */
  2960. EXTERN_API( OSStatus )
  2961. OTDeleteName(
  2962. MapperRef ref,
  2963. TNetbuf * name);
  2964. /*
  2965. * OTDeleteNameByID()
  2966. *
  2967. * Availability:
  2968. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2969. * CarbonLib: in CarbonLib 1.0 and later
  2970. * Mac OS X: in version 10.0 and later
  2971. */
  2972. EXTERN_API( OSStatus )
  2973. OTDeleteNameByID(
  2974. MapperRef ref,
  2975. OTNameID nameID);
  2976. /*
  2977. * OTLookupName()
  2978. *
  2979. * Availability:
  2980. * Non-Carbon CFM: in OTClientLib 1.0 and later
  2981. * CarbonLib: in CarbonLib 1.0 and later
  2982. * Mac OS X: in version 10.0 and later
  2983. */
  2984. EXTERN_API( OSStatus )
  2985. OTLookupName(
  2986. MapperRef ref,
  2987. TLookupRequest * req,
  2988. TLookupReply * reply);
  2989. /* Basic configuration manipulation*/
  2990. /*
  2991. * OTCreateConfiguration()
  2992. *
  2993. * Availability:
  2994. * Non-Carbon CFM: in OTClientUtilLib 1.0 and later
  2995. * CarbonLib: in CarbonLib 1.0 and later
  2996. * Mac OS X: in version 10.0 and later
  2997. */
  2998. EXTERN_API( OTConfigurationRef )
  2999. OTCreateConfiguration(const char * path);
  3000. /*
  3001. * OTCloneConfiguration()
  3002. *
  3003. * Availability:
  3004. * Non-Carbon CFM: in OTClientUtilLib 1.0 and later
  3005. * CarbonLib: in CarbonLib 1.0 and later
  3006. * Mac OS X: in version 10.0 and later
  3007. */
  3008. EXTERN_API( OTConfigurationRef )
  3009. OTCloneConfiguration(OTConfigurationRef cfig);
  3010. /*
  3011. * OTDestroyConfiguration()
  3012. *
  3013. * Availability:
  3014. * Non-Carbon CFM: in OTClientUtilLib 1.0 and later
  3015. * CarbonLib: in CarbonLib 1.0 and later
  3016. * Mac OS X: in version 10.0 and later
  3017. */
  3018. EXTERN_API( void )
  3019. OTDestroyConfiguration(OTConfigurationRef cfig);
  3020. /*
  3021. This file defines a very limited set of operations
  3022. on a configuration. "OpenTransportClient.h" extends this with extra
  3023. operations used by protocol stacks but not typically needed by clients.
  3024. */
  3025. /* Interrupt-safe memory allocators*/
  3026. /*
  3027. Under Carbon, OTAllocMem takes a client context pointer. Applications may pass NULL after
  3028. calling InitOpenTransport(kInitOTForApplicationMask, ...). Non-applications must always pass a
  3029. valid client context.
  3030. */
  3031. /*
  3032. * OTAllocMemInContext()
  3033. *
  3034. * Availability:
  3035. * Non-Carbon CFM: not available
  3036. * CarbonLib: in CarbonLib 1.0 and later
  3037. * Mac OS X: in version 10.0 and later
  3038. */
  3039. EXTERN_API_C( void * )
  3040. OTAllocMemInContext(
  3041. OTByteCount size,
  3042. OTClientContextPtr clientContext); /* can be NULL */
  3043. #if CALL_NOT_IN_CARBON
  3044. /*
  3045. * OTAllocMem()
  3046. *
  3047. * Availability:
  3048. * Non-Carbon CFM: not available
  3049. * CarbonLib: not available
  3050. * Mac OS X: not available
  3051. */
  3052. EXTERN_API_C( void * )
  3053. OTAllocMem(OTByteCount size);
  3054. #endif /* CALL_NOT_IN_CARBON */
  3055. /*
  3056. * OTFreeMem()
  3057. *
  3058. * Availability:
  3059. * Non-Carbon CFM: in OTClientUtilLib 1.0 and later
  3060. * CarbonLib: in CarbonLib 1.0 and later
  3061. * Mac OS X: in version 10.0 and later
  3062. */
  3063. EXTERN_API_C( void )
  3064. OTFreeMem(void * mem);
  3065. #if OTCARBONAPPLICATION
  3066. /* The following macros may be used by applications only.*/
  3067. #define OTAllocMem(s) OTAllocMemInContext(s, NULL)
  3068. #endif /* OTCARBONAPPLICATION */
  3069. /* Miscellaneous and Generic Routines*/
  3070. /*
  3071. Neither of these routines should be necessary to the correct
  3072. operation of an OT program. If you're calling them, think again.
  3073. */
  3074. /*
  3075. * OTDelay()
  3076. *
  3077. * Availability:
  3078. * Non-Carbon CFM: in OTClientLib 1.0 and later
  3079. * CarbonLib: in CarbonLib 1.0 and later
  3080. * Mac OS X: in version 10.0 and later
  3081. */
  3082. EXTERN_API( void )
  3083. OTDelay(UInt32 seconds);
  3084. /*
  3085. * OTIdle()
  3086. *
  3087. * Availability:
  3088. * Non-Carbon CFM: in OTClientLib 1.0 and later
  3089. * CarbonLib: in CarbonLib 1.0 and later
  3090. * Mac OS X: in version 10.0 and later
  3091. */
  3092. EXTERN_API( void )
  3093. OTIdle(void);
  3094. #endif /* !OTKERNEL */
  3095. /*
  3096. ***** Open Transport Utility Routines *****
  3097. All of these routines are available to both client and kernel.
  3098. */
  3099. /* Memory and String Routines*/
  3100. /*
  3101. These are preferable, especially in the kernel case, to the standard
  3102. C equivalents because they don't require you to link with StdCLib.
  3103. */
  3104. /*
  3105. * OTMemcpy()
  3106. *
  3107. * Availability:
  3108. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3109. * CarbonLib: in CarbonLib 1.0 and later
  3110. * Mac OS X: in version 10.0 and later
  3111. */
  3112. EXTERN_API_C( void )
  3113. OTMemcpy(
  3114. void * dest,
  3115. const void * src,
  3116. OTByteCount nBytes);
  3117. /*
  3118. * OTMemcmp()
  3119. *
  3120. * Availability:
  3121. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3122. * CarbonLib: in CarbonLib 1.0 and later
  3123. * Mac OS X: in version 10.0 and later
  3124. */
  3125. EXTERN_API_C( Boolean )
  3126. OTMemcmp(
  3127. const void * mem1,
  3128. const void * mem2,
  3129. OTByteCount nBytes);
  3130. /*
  3131. * OTMemmove()
  3132. *
  3133. * Availability:
  3134. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3135. * CarbonLib: in CarbonLib 1.0 and later
  3136. * Mac OS X: in version 10.0 and later
  3137. */
  3138. EXTERN_API_C( void )
  3139. OTMemmove(
  3140. void * dest,
  3141. const void * src,
  3142. OTByteCount nBytes);
  3143. /*
  3144. * OTMemzero()
  3145. *
  3146. * Availability:
  3147. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3148. * CarbonLib: in CarbonLib 1.0 and later
  3149. * Mac OS X: in version 10.0 and later
  3150. */
  3151. EXTERN_API_C( void )
  3152. OTMemzero(
  3153. void * dest,
  3154. OTByteCount nBytes);
  3155. /*
  3156. * OTMemset()
  3157. *
  3158. * Availability:
  3159. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3160. * CarbonLib: in CarbonLib 1.0 and later
  3161. * Mac OS X: in version 10.0 and later
  3162. */
  3163. EXTERN_API_C( void )
  3164. OTMemset(
  3165. void * dest,
  3166. OTUInt8Param toSet,
  3167. OTByteCount nBytes);
  3168. /*
  3169. * OTStrLength()
  3170. *
  3171. * Availability:
  3172. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3173. * CarbonLib: in CarbonLib 1.0 and later
  3174. * Mac OS X: in version 10.0 and later
  3175. */
  3176. EXTERN_API_C( OTByteCount )
  3177. OTStrLength(const char * str);
  3178. /*
  3179. * OTStrCopy()
  3180. *
  3181. * Availability:
  3182. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3183. * CarbonLib: in CarbonLib 1.0 and later
  3184. * Mac OS X: in version 10.0 and later
  3185. */
  3186. EXTERN_API_C( void )
  3187. OTStrCopy(
  3188. char * dest,
  3189. const char * src);
  3190. /*
  3191. * OTStrCat()
  3192. *
  3193. * Availability:
  3194. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3195. * CarbonLib: in CarbonLib 1.0 and later
  3196. * Mac OS X: in version 10.0 and later
  3197. */
  3198. EXTERN_API_C( void )
  3199. OTStrCat(
  3200. char * dest,
  3201. const char * src);
  3202. /*
  3203. * OTStrEqual()
  3204. *
  3205. * Availability:
  3206. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3207. * CarbonLib: in CarbonLib 1.0 and later
  3208. * Mac OS X: in version 10.0 and later
  3209. */
  3210. EXTERN_API_C( Boolean )
  3211. OTStrEqual(
  3212. const char * src1,
  3213. const char * src2);
  3214. /* Timer Utilities*/
  3215. /*
  3216. OTGetTimeStamp returns time in "tick" numbers, stored in 64 bits.
  3217. This timestamp can be used as a base number for calculating elapsed
  3218. time.
  3219. OTSubtractTimeStamps returns a pointer to the "result" parameter.
  3220. OTGetClockTimeInSecs returns time since Open Transport was initialized
  3221. in seconds.
  3222. */
  3223. typedef UnsignedWide OTTimeStamp;
  3224. /*
  3225. * OTGetTimeStamp()
  3226. *
  3227. * Availability:
  3228. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3229. * CarbonLib: in CarbonLib 1.0 and later
  3230. * Mac OS X: in version 10.0 and later
  3231. */
  3232. EXTERN_API_C( void )
  3233. OTGetTimeStamp(OTTimeStamp * currentTime);
  3234. /*
  3235. * OTSubtractTimeStamps()
  3236. *
  3237. * Availability:
  3238. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3239. * CarbonLib: in CarbonLib 1.0 and later
  3240. * Mac OS X: in version 10.0 and later
  3241. */
  3242. EXTERN_API_C( OTTimeStamp * )
  3243. OTSubtractTimeStamps(
  3244. OTTimeStamp * result,
  3245. OTTimeStamp * startTime,
  3246. OTTimeStamp * endEnd);
  3247. /*
  3248. * OTTimeStampInMilliseconds()
  3249. *
  3250. * Availability:
  3251. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3252. * CarbonLib: in CarbonLib 1.0 and later
  3253. * Mac OS X: in version 10.0 and later
  3254. */
  3255. EXTERN_API_C( UInt32 )
  3256. OTTimeStampInMilliseconds(OTTimeStamp * delta);
  3257. /*
  3258. * OTTimeStampInMicroseconds()
  3259. *
  3260. * Availability:
  3261. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3262. * CarbonLib: in CarbonLib 1.0 and later
  3263. * Mac OS X: in version 10.0 and later
  3264. */
  3265. EXTERN_API_C( UInt32 )
  3266. OTTimeStampInMicroseconds(OTTimeStamp * delta);
  3267. /*
  3268. * OTElapsedMilliseconds()
  3269. *
  3270. * Availability:
  3271. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3272. * CarbonLib: in CarbonLib 1.0 and later
  3273. * Mac OS X: in version 10.0 and later
  3274. */
  3275. EXTERN_API_C( UInt32 )
  3276. OTElapsedMilliseconds(OTTimeStamp * startTime);
  3277. /*
  3278. * OTElapsedMicroseconds()
  3279. *
  3280. * Availability:
  3281. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3282. * CarbonLib: in CarbonLib 1.0 and later
  3283. * Mac OS X: in version 10.0 and later
  3284. */
  3285. EXTERN_API_C( UInt32 )
  3286. OTElapsedMicroseconds(OTTimeStamp * startTime);
  3287. /*
  3288. * OTGetClockTimeInSecs()
  3289. *
  3290. * Availability:
  3291. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3292. * CarbonLib: in CarbonLib 1.0 and later
  3293. * Mac OS X: in version 10.0 and later
  3294. */
  3295. EXTERN_API_C( UInt32 )
  3296. OTGetClockTimeInSecs(void);
  3297. /* ***** OT Link Element ******/
  3298. /*
  3299. When using OT linked lists, all pointers to other elements are
  3300. represented by the OTLink structure. When operating on link
  3301. lists, you always pass in the address of the OTLink on which
  3302. list elements are chained.
  3303. */
  3304. struct OTLink {
  3305. struct OTLink * fNext;
  3306. #ifdef __cplusplus
  3307. // C++ inline methods on this structure.
  3308. void Init() { fNext = NULL; }
  3309. #endif
  3310. };
  3311. typedef struct OTLink OTLink;
  3312. /*
  3313. You can use this macro to map from an OTLink field to the
  3314. structure in which it's embedded.
  3315. */
  3316. #define OTGetLinkObject(link, struc, field) \
  3317. ((struc*)((char*)(link) - OTOffsetOf(struc, field)))
  3318. /* OTLIFO*/
  3319. /*
  3320. These are functions to implement a LIFO list that is interrupt-safe.
  3321. The only function which is not is OTReverseList. Normally, you create
  3322. a LIFO list, populate it at interrupt time, and then use OTLIFOStealList
  3323. to atomically remove the list, and OTReverseList to flip the list so that
  3324. it is a FIFO list, which tends to be more useful.
  3325. */
  3326. struct OTLIFO {
  3327. OTLink * fHead;
  3328. #ifdef __cplusplus
  3329. // C++ inline methods on this structure.
  3330. void Init();
  3331. void Enqueue(OTLink* link);
  3332. OTLink* Dequeue();
  3333. OTLink* StealList();
  3334. Boolean IsEmpty();
  3335. #endif
  3336. };
  3337. typedef struct OTLIFO OTLIFO;
  3338. /*
  3339. This function atomically enqueues the link onto the
  3340. front of the list.
  3341. */
  3342. /*
  3343. * OTLIFOEnqueue()
  3344. *
  3345. * Availability:
  3346. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3347. * CarbonLib: in CarbonLib 1.0 and later
  3348. * Mac OS X: in version 10.0 and later
  3349. */
  3350. EXTERN_API_C( void )
  3351. OTLIFOEnqueue(
  3352. OTLIFO * list,
  3353. OTLink * link);
  3354. /*
  3355. This function atomically dequeues the first element
  3356. on the list.
  3357. */
  3358. /*
  3359. * OTLIFODequeue()
  3360. *
  3361. * Availability:
  3362. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3363. * CarbonLib: in CarbonLib 1.0 and later
  3364. * Mac OS X: in version 10.0 and later
  3365. */
  3366. EXTERN_API_C( OTLink * )
  3367. OTLIFODequeue(OTLIFO * list);
  3368. /*
  3369. This function atomically empties the list and returns a
  3370. pointer to the first element on the list.
  3371. */
  3372. /*
  3373. * OTLIFOStealList()
  3374. *
  3375. * Availability:
  3376. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3377. * CarbonLib: in CarbonLib 1.0 and later
  3378. * Mac OS X: in version 10.0 and later
  3379. */
  3380. EXTERN_API_C( OTLink * )
  3381. OTLIFOStealList(OTLIFO * list);
  3382. /*
  3383. This function reverses a list that was stolen by
  3384. OTLIFOStealList. It is NOT atomic. It returns the
  3385. new starting list.
  3386. */
  3387. /*
  3388. * OTReverseList()
  3389. *
  3390. * Availability:
  3391. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3392. * CarbonLib: in CarbonLib 1.0 and later
  3393. * Mac OS X: in version 10.0 and later
  3394. */
  3395. EXTERN_API_C( OTLink * )
  3396. OTReverseList(OTLink * list);
  3397. #ifdef __cplusplus
  3398. // C++ inline methods on this structure.
  3399. inline void OTLIFO::Init() { fHead = NULL; }
  3400. inline void OTLIFO::Enqueue(OTLink* link) { OTLIFOEnqueue(this, link); }
  3401. inline OTLink* OTLIFO::Dequeue() { return OTLIFODequeue(this); }
  3402. inline OTLink* OTLIFO::StealList() { return OTLIFOStealList(this); }
  3403. inline Boolean OTLIFO::IsEmpty() { return fHead == NULL; }
  3404. #endif
  3405. /* OTList*/
  3406. /*
  3407. An OTList is a non-interrupt-safe list, but has more features than the
  3408. OTLIFO list. It is a standard singly-linked list.
  3409. */
  3410. /*
  3411. The following is the prototype for a list element comparison function,
  3412. which returns true if the element described by linkToCheck matches
  3413. the client criteria (typically held in ref).
  3414. This is only a UPP for CFM-68K clients.
  3415. */
  3416. typedef CALLBACK_API_C( Boolean , OTListSearchProcPtr )(const void *ref, OTLink *linkToCheck);
  3417. typedef TVECTOR_UPP_TYPE(OTListSearchProcPtr) OTListSearchUPP;
  3418. /*
  3419. * NewOTListSearchUPP()
  3420. *
  3421. * Availability:
  3422. * Non-Carbon CFM: available as macro/inline
  3423. * CarbonLib: in CarbonLib 1.0 and later
  3424. * Mac OS X: in version 10.0 and later
  3425. */
  3426. EXTERN_API_C( OTListSearchUPP )
  3427. NewOTListSearchUPP(OTListSearchProcPtr userRoutine);
  3428. #if !OPAQUE_UPP_TYPES
  3429. enum { uppOTListSearchProcInfo = 0x000003D1 }; /* 1_byte Func(4_bytes, 4_bytes) */
  3430. #ifdef __cplusplus
  3431. inline DEFINE_API_C(OTListSearchUPP) NewOTListSearchUPP(OTListSearchProcPtr userRoutine) { return userRoutine; }
  3432. #else
  3433. #define NewOTListSearchUPP(userRoutine) (userRoutine)
  3434. #endif
  3435. #endif
  3436. /*
  3437. * DisposeOTListSearchUPP()
  3438. *
  3439. * Availability:
  3440. * Non-Carbon CFM: available as macro/inline
  3441. * CarbonLib: in CarbonLib 1.0 and later
  3442. * Mac OS X: in version 10.0 and later
  3443. */
  3444. EXTERN_API_C( void )
  3445. DisposeOTListSearchUPP(OTListSearchUPP userUPP);
  3446. #if !OPAQUE_UPP_TYPES
  3447. #ifdef __cplusplus
  3448. inline DEFINE_API_C(void) DisposeOTListSearchUPP(OTListSearchUPP) {}
  3449. #else
  3450. #define DisposeOTListSearchUPP(userUPP)
  3451. #endif
  3452. #endif
  3453. /*
  3454. * InvokeOTListSearchUPP()
  3455. *
  3456. * Availability:
  3457. * Non-Carbon CFM: available as macro/inline
  3458. * CarbonLib: in CarbonLib 1.0 and later
  3459. * Mac OS X: in version 10.0 and later
  3460. */
  3461. EXTERN_API_C( Boolean )
  3462. InvokeOTListSearchUPP(
  3463. const void * ref,
  3464. OTLink * linkToCheck,
  3465. OTListSearchUPP userUPP);
  3466. #if !OPAQUE_UPP_TYPES
  3467. #ifdef __cplusplus
  3468. inline DEFINE_API_C(Boolean) InvokeOTListSearchUPP(const void * ref, OTLink * linkToCheck, OTListSearchUPP userUPP) { return (*userUPP)(ref, linkToCheck); }
  3469. #else
  3470. #define InvokeOTListSearchUPP(ref, linkToCheck, userUPP) (*userUPP)(ref, linkToCheck)
  3471. #endif
  3472. #endif
  3473. struct OTList {
  3474. OTLink * fHead;
  3475. #ifdef __cplusplus
  3476. // C++ inline methods on this structure.
  3477. void Init();
  3478. Boolean IsEmpty();
  3479. void AddFirst(OTLink* link);
  3480. void AddLast(OTLink* link);
  3481. OTLink* GetFirst();
  3482. OTLink* GetLast();
  3483. OTLink* RemoveFirst();
  3484. OTLink* RemoveLast();
  3485. Boolean IsInList(OTLink* link);
  3486. OTLink* FindLink(OTListSearchUPP proc, const void* ref);
  3487. Boolean RemoveLink(OTLink* link);
  3488. OTLink* FindAndRemoveLink(OTListSearchUPP proc, const void* ref);
  3489. OTLink* GetIndexedLink(OTItemCount index);
  3490. #endif
  3491. };
  3492. typedef struct OTList OTList;
  3493. /* Add the link to the list at the front*/
  3494. /*
  3495. * OTAddFirst()
  3496. *
  3497. * Availability:
  3498. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3499. * CarbonLib: in CarbonLib 1.0 and later
  3500. * Mac OS X: in version 10.0 and later
  3501. */
  3502. EXTERN_API_C( void )
  3503. OTAddFirst(
  3504. OTList * list,
  3505. OTLink * link);
  3506. /* Add the link to the list at the end*/
  3507. /*
  3508. * OTAddLast()
  3509. *
  3510. * Availability:
  3511. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3512. * CarbonLib: in CarbonLib 1.0 and later
  3513. * Mac OS X: in version 10.0 and later
  3514. */
  3515. EXTERN_API_C( void )
  3516. OTAddLast(
  3517. OTList * list,
  3518. OTLink * link);
  3519. /* Remove the first link from the list*/
  3520. /*
  3521. * OTRemoveFirst()
  3522. *
  3523. * Availability:
  3524. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3525. * CarbonLib: in CarbonLib 1.0 and later
  3526. * Mac OS X: in version 10.0 and later
  3527. */
  3528. EXTERN_API_C( OTLink * )
  3529. OTRemoveFirst(OTList * list);
  3530. /* Remove the last link from the list*/
  3531. /*
  3532. * OTRemoveLast()
  3533. *
  3534. * Availability:
  3535. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3536. * CarbonLib: in CarbonLib 1.0 and later
  3537. * Mac OS X: in version 10.0 and later
  3538. */
  3539. EXTERN_API_C( OTLink * )
  3540. OTRemoveLast(OTList * list);
  3541. /* Return the first link from the list*/
  3542. /*
  3543. * OTGetFirst()
  3544. *
  3545. * Availability:
  3546. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3547. * CarbonLib: in CarbonLib 1.0 and later
  3548. * Mac OS X: in version 10.0 and later
  3549. */
  3550. EXTERN_API_C( OTLink * )
  3551. OTGetFirst(OTList * list);
  3552. /* Return the last link from the list*/
  3553. /*
  3554. * OTGetLast()
  3555. *
  3556. * Availability:
  3557. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3558. * CarbonLib: in CarbonLib 1.0 and later
  3559. * Mac OS X: in version 10.0 and later
  3560. */
  3561. EXTERN_API_C( OTLink * )
  3562. OTGetLast(OTList * list);
  3563. /* Return true if the link is present in the list*/
  3564. /*
  3565. * OTIsInList()
  3566. *
  3567. * Availability:
  3568. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3569. * CarbonLib: in CarbonLib 1.0 and later
  3570. * Mac OS X: in version 10.0 and later
  3571. */
  3572. EXTERN_API_C( Boolean )
  3573. OTIsInList(
  3574. OTList * list,
  3575. OTLink * link);
  3576. /*
  3577. Find a link in the list which matches the search criteria
  3578. established by the search proc and the refPtr. This is done
  3579. by calling the search proc, passing it the refPtr and each
  3580. link in the list, until the search proc returns true.
  3581. NULL is returned if the search proc never returned true.
  3582. */
  3583. /*
  3584. * OTFindLink()
  3585. *
  3586. * Availability:
  3587. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3588. * CarbonLib: in CarbonLib 1.0 and later
  3589. * Mac OS X: in version 10.0 and later
  3590. */
  3591. EXTERN_API_C( OTLink * )
  3592. OTFindLink(
  3593. OTList * list,
  3594. OTListSearchUPP proc,
  3595. const void * ref);
  3596. /* Remove the specified link from the list, returning true if it was found*/
  3597. /*
  3598. * OTRemoveLink()
  3599. *
  3600. * Availability:
  3601. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3602. * CarbonLib: in CarbonLib 1.0 and later
  3603. * Mac OS X: in version 10.0 and later
  3604. */
  3605. EXTERN_API_C( Boolean )
  3606. OTRemoveLink(
  3607. OTList * list,
  3608. OTLink * link);
  3609. /* Similar to OTFindLink, but it also removes it from the list.*/
  3610. /*
  3611. * OTFindAndRemoveLink()
  3612. *
  3613. * Availability:
  3614. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3615. * CarbonLib: in CarbonLib 1.0 and later
  3616. * Mac OS X: in version 10.0 and later
  3617. */
  3618. EXTERN_API_C( OTLink * )
  3619. OTFindAndRemoveLink(
  3620. OTList * list,
  3621. OTListSearchUPP proc,
  3622. const void * ref);
  3623. /* Return the "index"th link in the list*/
  3624. /*
  3625. * OTGetIndexedLink()
  3626. *
  3627. * Availability:
  3628. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3629. * CarbonLib: in CarbonLib 1.0 and later
  3630. * Mac OS X: in version 10.0 and later
  3631. */
  3632. EXTERN_API_C( OTLink * )
  3633. OTGetIndexedLink(
  3634. OTList * list,
  3635. OTItemCount index);
  3636. /* OTEnqueue/OTDequeue*/
  3637. /*
  3638. These routines are atomic, mighty weird, and generally not
  3639. worth the complexity. If you need atomic list operations,
  3640. use OTLIFO instead.
  3641. */
  3642. /*
  3643. This function puts "object" on the listHead, and places the
  3644. previous value at listHead into the pointer at "object" plus
  3645. linkOffset.
  3646. */
  3647. /*
  3648. * OTEnqueue()
  3649. *
  3650. * Availability:
  3651. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3652. * CarbonLib: in CarbonLib 1.0 and later
  3653. * Mac OS X: in version 10.0 and later
  3654. */
  3655. EXTERN_API_C( void )
  3656. OTEnqueue(
  3657. void ** listHead,
  3658. void * object,
  3659. OTByteCount linkOffset);
  3660. /*
  3661. This function returns the head object of the list, and places
  3662. the pointer at "object" + linkOffset into the listHead
  3663. */
  3664. /*
  3665. * OTDequeue()
  3666. *
  3667. * Availability:
  3668. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3669. * CarbonLib: in CarbonLib 1.0 and later
  3670. * Mac OS X: in version 10.0 and later
  3671. */
  3672. EXTERN_API_C( void * )
  3673. OTDequeue(
  3674. void ** listHead,
  3675. OTByteCount linkOffset);
  3676. #ifdef __cplusplus
  3677. // C++ inline methods on this structure.
  3678. inline void OTList::Init() { fHead = NULL; }
  3679. inline Boolean OTList::IsEmpty() { return fHead == NULL; }
  3680. inline void OTList::AddFirst(OTLink* link) { OTAddFirst(this, link); }
  3681. inline void OTList::AddLast(OTLink* link) { OTAddLast(this, link); }
  3682. inline OTLink* OTList::GetFirst() { return OTGetFirst(this); }
  3683. inline OTLink* OTList::GetLast() { return OTGetLast(this); }
  3684. inline OTLink* OTList::RemoveFirst() { return OTRemoveFirst(this); }
  3685. inline OTLink* OTList::RemoveLast() { return OTRemoveLast(this); }
  3686. inline Boolean OTList::IsInList(OTLink* link) { return OTIsInList(this, link); }
  3687. inline OTLink* OTList::FindLink(OTListSearchUPP proc, const void* ref)
  3688. { return OTFindLink(this, proc, ref); }
  3689. inline Boolean OTList::RemoveLink(OTLink* link) { return OTRemoveLink(this, link); }
  3690. inline OTLink* OTList::FindAndRemoveLink(OTListSearchUPP proc, const void* ref)
  3691. { return OTFindAndRemoveLink(this, proc, ref); }
  3692. inline OTLink* OTList::GetIndexedLink(OTItemCount index)
  3693. { return OTGetIndexedLink(this, index); }
  3694. #endif
  3695. /* Atomic Operations*/
  3696. /*
  3697. Note:
  3698. The Bit operations return the previous value of the bit (0 or non-zero).
  3699. The memory pointed to must be a single byte and only bits 0 through 7 are
  3700. valid. Bit 0 corresponds to a mask of 0x01, and Bit 7 to a mask of 0x80.
  3701. */
  3702. /*
  3703. WARNING!
  3704. void* and UInt32 locations MUST be on 4-byte boundaries.
  3705. UInt16 locations must not cross a 4-byte boundary.
  3706. */
  3707. /*
  3708. * OTAtomicSetBit()
  3709. *
  3710. * Availability:
  3711. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3712. * CarbonLib: in CarbonLib 1.0 and later
  3713. * Mac OS X: in version 10.0 and later
  3714. */
  3715. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  3716. #pragma parameter __D0 OTAtomicSetBit(__A0, __D0)
  3717. #endif
  3718. EXTERN_API_C( Boolean )
  3719. OTAtomicSetBit(
  3720. UInt8 * bytePtr,
  3721. OTByteCount bitNumber) FOURWORDINLINE(0x01D0, 0x56C0, 0x7201, 0xC081);
  3722. /*
  3723. bset.b d0,(a0)
  3724. sne d0
  3725. moveq #1,d1
  3726. and.l d1,d0
  3727. */
  3728. /*
  3729. * OTAtomicClearBit()
  3730. *
  3731. * Availability:
  3732. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3733. * CarbonLib: in CarbonLib 1.0 and later
  3734. * Mac OS X: in version 10.0 and later
  3735. */
  3736. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  3737. #pragma parameter __D0 OTAtomicClearBit(__A0, __D0)
  3738. #endif
  3739. EXTERN_API_C( Boolean )
  3740. OTAtomicClearBit(
  3741. UInt8 * bytePtr,
  3742. OTByteCount bitNumber) FOURWORDINLINE(0x0190, 0x56C0, 0x7201, 0xC081);
  3743. /*
  3744. bclr.b d0,(a0)
  3745. sne d0
  3746. moveq #1,d1
  3747. and.l d1,d0
  3748. */
  3749. /*
  3750. * OTAtomicTestBit()
  3751. *
  3752. * Availability:
  3753. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3754. * CarbonLib: in CarbonLib 1.0 and later
  3755. * Mac OS X: in version 10.0 and later
  3756. */
  3757. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  3758. #pragma parameter __D0 OTAtomicTestBit(__A0, __D0)
  3759. #endif
  3760. EXTERN_API_C( Boolean )
  3761. OTAtomicTestBit(
  3762. UInt8 * bytePtr,
  3763. OTByteCount bitNumber) FOURWORDINLINE(0x0110, 0x56C0, 0x7201, 0xC081);
  3764. /*
  3765. btst.b d0,(a0)
  3766. sne d0 *|
  3767. moveq #1,d1
  3768. and.l d1,d0 *|
  3769. */
  3770. /*
  3771. * OTCompareAndSwapPtr()
  3772. *
  3773. * Availability:
  3774. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3775. * CarbonLib: in CarbonLib 1.0 and later
  3776. * Mac OS X: in version 10.0 and later
  3777. */
  3778. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  3779. #pragma parameter __D0 OTCompareAndSwapPtr(__D0, __D1, __A0)
  3780. #endif
  3781. EXTERN_API_C( Boolean )
  3782. OTCompareAndSwapPtr(
  3783. void * oldValue,
  3784. void * newValue,
  3785. void ** dest) FIVEWORDINLINE(0x0ED0, 0x0040, 0x57C0, 0x7201, 0xC081);
  3786. /*
  3787. cas.l d0,d1,(a0) *|
  3788. seq d0 *|
  3789. moveq #1,d1; and.l d1,d0 *|
  3790. */
  3791. /*
  3792. * OTCompareAndSwap32()
  3793. *
  3794. * Availability:
  3795. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3796. * CarbonLib: in CarbonLib 1.0 and later
  3797. * Mac OS X: in version 10.0 and later
  3798. */
  3799. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  3800. #pragma parameter __D0 OTCompareAndSwap32(__D0, __D1, __A0)
  3801. #endif
  3802. EXTERN_API_C( Boolean )
  3803. OTCompareAndSwap32(
  3804. UInt32 oldValue,
  3805. UInt32 newValue,
  3806. UInt32 * dest) FIVEWORDINLINE(0x0ED0, 0x0040, 0x57C0, 0x7201, 0xC081);
  3807. /*
  3808. cas.l d0,d1,(a0) *|
  3809. seq d0 *|
  3810. moveq #1,d1; and.l d1,d0 *|
  3811. */
  3812. /*
  3813. * OTCompareAndSwap16()
  3814. *
  3815. * Availability:
  3816. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3817. * CarbonLib: in CarbonLib 1.0 and later
  3818. * Mac OS X: in version 10.0 and later
  3819. */
  3820. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  3821. #pragma parameter __D0 OTCompareAndSwap16(__D0, __D1, __A0)
  3822. #endif
  3823. EXTERN_API_C( Boolean )
  3824. OTCompareAndSwap16(
  3825. UInt32 oldValue,
  3826. UInt32 newValue,
  3827. UInt16 * dest) FIVEWORDINLINE(0x0CD0, 0x0040, 0x57C0, 0x7201, 0xC081);
  3828. /*
  3829. cas.w d0,d1,(a0) *|
  3830. seq d0 *|
  3831. moveq #1,d1; and.l d1,d0 *|
  3832. */
  3833. /*
  3834. * OTCompareAndSwap8()
  3835. *
  3836. * Availability:
  3837. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3838. * CarbonLib: in CarbonLib 1.0 and later
  3839. * Mac OS X: in version 10.0 and later
  3840. */
  3841. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  3842. #pragma parameter __D0 OTCompareAndSwap8(__D0, __D1, __A0)
  3843. #endif
  3844. EXTERN_API_C( Boolean )
  3845. OTCompareAndSwap8(
  3846. UInt32 oldValue,
  3847. UInt32 newValue,
  3848. UInt8 * dest) FIVEWORDINLINE(0x0AD0, 0x0040, 0x57C0, 0x7201, 0xC081);
  3849. /*
  3850. cas.b d0,d1,(a0) *|
  3851. seq d0 *|
  3852. moveq #1,d1; and.l d1,d0 *|
  3853. */
  3854. /*
  3855. * OTAtomicAdd32()
  3856. *
  3857. * Availability:
  3858. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3859. * CarbonLib: in CarbonLib 1.0 and later
  3860. * Mac OS X: in version 10.0 and later
  3861. */
  3862. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  3863. #pragma parameter __D0 OTAtomicAdd32(__D0, __A0)
  3864. #endif
  3865. EXTERN_API_C( SInt32 )
  3866. OTAtomicAdd32(
  3867. SInt32 toAdd,
  3868. SInt32 * dest) SEVENWORDINLINE(0x2240, 0x2210, 0x2001, 0xD089, 0x0ED0, 0x0001, 0x66F4);
  3869. /*
  3870. move.l d0,a1 *|
  3871. move.l (a0),d1 *|
  3872. move.l d1,d0 *|
  3873. add.l a1,d0 *|
  3874. cas.l d1,d0,(a0) *|
  3875. bne.s @1 *|
  3876. */
  3877. /*
  3878. * OTAtomicAdd16()
  3879. *
  3880. * Availability:
  3881. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3882. * CarbonLib: in CarbonLib 1.0 and later
  3883. * Mac OS X: in version 10.0 and later
  3884. */
  3885. EXTERN_API_C( SInt16 )
  3886. OTAtomicAdd16(
  3887. SInt32 toAdd,
  3888. SInt16 * dest);
  3889. /* Not used frequently enough to justify inlining.*/
  3890. /*
  3891. * OTAtomicAdd8()
  3892. *
  3893. * Availability:
  3894. * Non-Carbon CFM: in OTUtilityLib 1.0 and later
  3895. * CarbonLib: in CarbonLib 1.0 and later
  3896. * Mac OS X: in version 10.0 and later
  3897. */
  3898. EXTERN_API_C( SInt8 )
  3899. OTAtomicAdd8(
  3900. SInt32 toAdd,
  3901. SInt8 * dest);
  3902. /* Not used frequently enough to justify inlining.*/
  3903. /* OTLock is just a convenience type with some convenient macros.*/
  3904. typedef UInt8 OTLock;
  3905. #define OTClearLock(lockPtr) *(lockPtr) = 0
  3906. #define OTAcquireLock(lockPtr) (OTAtomicSetBit(lockPtr, 0) == 0)
  3907. /*******************************************************************************
  3908. **
  3909. ** FROM HERE ON DOWN ARE THE C++ Interfaces to Open Transport
  3910. **
  3911. ********************************************************************************/
  3912. #ifdef __cplusplus
  3913. } // Terminate C definitions
  3914. /* -------------------------------------------------------------------------
  3915. CLASS TProvider
  3916. This class provides the client interface to a Stream. Typically, clients
  3917. talk to an object (or glue code in front of the object) that is a subclass
  3918. of TProvider.
  3919. ------------------------------------------------------------------------- */
  3920. #if !OTKERNEL
  3921. class TProvider
  3922. {
  3923. private:
  3924. void* operator new(size_t);
  3925. void operator delete(void*) {}
  3926. //
  3927. // This is the public interface to a TProvider. All other public
  3928. // methods normally come from the subclass.
  3929. //
  3930. public:
  3931. OSStatus Close() { return OTCloseProvider(this); }
  3932. OSStatus SetNonBlocking() { return OTSetNonBlocking(this); }
  3933. OSStatus SetBlocking() { return OTSetBlocking(this); }
  3934. Boolean IsBlocking() { return OTIsBlocking(this); }
  3935. Boolean IsNonBlocking() { return !OTIsBlocking(this); }
  3936. OSStatus SetSynchronous() { return OTSetSynchronous(this); }
  3937. OSStatus SetAsynchronous() { return OTSetAsynchronous(this); }
  3938. Boolean IsSynchronous() { return OTIsSynchronous(this); }
  3939. Boolean IsAsynchronous() { return !OTIsSynchronous(this); }
  3940. OSStatus AckSends() { return OTAckSends(this); }
  3941. OSStatus DontAckSends() { return OTDontAckSends(this); }
  3942. Boolean IsAckingSends() { return OTIsAckingSends(this); }
  3943. void CancelSynchronousCalls(OSStatus err)
  3944. { (void)OTCancelSynchronousCalls(this, err); }
  3945. OSStatus InstallNotifier(OTNotifyUPP proc, void* ptr)
  3946. { return OTInstallNotifier(this, proc, ptr); }
  3947. OSStatus UseSyncIdleEvents()
  3948. { return OTUseSyncIdleEvents(this, true); }
  3949. OSStatus DontUseSyncIdleEvents()
  3950. { return OTUseSyncIdleEvents(this, false); }
  3951. void RemoveNotifier()
  3952. { OTRemoveNotifier(this); }
  3953. Boolean EnterNotifier()
  3954. { return OTEnterNotifier(this); }
  3955. void LeaveNotifier()
  3956. { OTLeaveNotifier(this); }
  3957. #if CALL_NOT_IN_CARBON
  3958. OTPortRef GetOTPortRef()
  3959. { return OTGetProviderPortRef(this); }
  3960. ProviderRef TransferOwnership(OTClient prevOwner, OSStatus* errPtr)
  3961. { return OTTransferProviderOwnership(this, prevOwner, errPtr); }
  3962. #endif
  3963. SInt32 Ioctl(UInt32 cmd, void* data)
  3964. { return OTIoctl(this, cmd, data); }
  3965. SInt32 Ioctl(UInt32 cmd, long data)
  3966. { return OTIoctl(this, cmd, (void*)data); }
  3967. #if CALL_NOT_IN_CARBON
  3968. OTResult GetMessage(strbuf* ctlbuf, strbuf* databuf, OTFlags* flagPtr)
  3969. { return OTGetMessage(this, ctlbuf, databuf, flagPtr); }
  3970. OTResult GetPriorityMessage(strbuf* ctlbuf, strbuf* databuf,
  3971. OTBand* bandPtr, OTFlags* flagPtr)
  3972. { return OTGetPriorityMessage(this, ctlbuf, databuf, bandPtr, flagPtr); }
  3973. OSStatus PutMessage(const strbuf* ctlbuf, const strbuf* databuf,
  3974. OTFlags flags)
  3975. { return OTPutMessage(this, ctlbuf, databuf, flags); }
  3976. OSStatus PutPriorityMessage(const strbuf* ctlbuf, const strbuf* databuf,
  3977. OTBand band, OTFlags flags)
  3978. { return OTPutPriorityMessage(this, ctlbuf, databuf, band, flags); }
  3979. #endif
  3980. };
  3981. /* -------------------------------------------------------------------------
  3982. Class TEndpoint
  3983. This class is the interface to all TPI modules, which constitute the
  3984. vast majority of protocols, with the exception of link-layer protocols.
  3985. ------------------------------------------------------------------------- */
  3986. class TEndpoint : public TProvider
  3987. {
  3988. public:
  3989. //
  3990. // Miscellaneous informative functions
  3991. //
  3992. OSStatus GetEndpointInfo(TEndpointInfo* info)
  3993. { return OTGetEndpointInfo(this, info); }
  3994. OSStatus GetProtAddress(TBind* boundAddr, TBind* peerAddr)
  3995. { return OTGetProtAddress(this, boundAddr, peerAddr); }
  3996. OSStatus ResolveAddress(TBind* reqAddr, TBind* retAddr, OTTimeout timeout)
  3997. { return OTResolveAddress(this, reqAddr, retAddr, timeout); }
  3998. OTResult GetEndpointState()
  3999. { return OTGetEndpointState(this); }
  4000. OTResult Look()
  4001. { return OTLook(this); }
  4002. #if CALL_NOT_IN_CARBON
  4003. OTResult Sync()
  4004. { return OTSync(this); }
  4005. #endif
  4006. //
  4007. // Allocating structures
  4008. //
  4009. void* AllocInContext(OTStructType structType, UInt32 fields, OSStatus* err = NULL, OTClientContextPtr clientContext = NULL)
  4010. { return OTAllocInContext(this, structType, fields, err, clientContext); }
  4011. void* Alloc(OTStructType structType, UInt32 fields, OSStatus* err = NULL)
  4012. {
  4013. #if TARGET_API_MAC_CARBON
  4014. return OTAllocInContext(this, structType, fields, err, NULL);
  4015. #else
  4016. return OTAlloc(this, structType, fields, err);
  4017. #endif
  4018. };
  4019. OTResult Free(void* ptr, OTStructType structType)
  4020. { return OTFree(ptr, structType); }
  4021. //
  4022. // Option Management
  4023. //
  4024. OSStatus OptionManagement(TOptMgmt* req, TOptMgmt* ret)
  4025. { return OTOptionManagement(this, req, ret); }
  4026. //
  4027. // Bind/Unbind
  4028. //
  4029. OSStatus Bind(TBind* reqAddr, TBind* retAddr)
  4030. { return OTBind(this, reqAddr, retAddr); }
  4031. OSStatus Unbind()
  4032. { return OTUnbind(this); }
  4033. //
  4034. // Connection creation and tear-down
  4035. //
  4036. OSStatus Connect(TCall* sndCall, TCall* rcvCall)
  4037. { return OTConnect(this, sndCall, rcvCall); }
  4038. OSStatus RcvConnect(TCall* call)
  4039. { return OTRcvConnect(this, call); }
  4040. OSStatus Listen(TCall* call)
  4041. { return OTListen(this, call); }
  4042. OSStatus Accept(EndpointRef resRef, TCall* call)
  4043. { return OTAccept(this, resRef, call); }
  4044. OSStatus SndDisconnect(TCall* call)
  4045. { return OTSndDisconnect(this, call); }
  4046. OSStatus SndOrderlyDisconnect()
  4047. { return OTSndOrderlyDisconnect(this); }
  4048. OSStatus RcvDisconnect(TDiscon* discon)
  4049. { return OTRcvDisconnect(this, discon); }
  4050. OSStatus RcvOrderlyDisconnect()
  4051. { return OTRcvOrderlyDisconnect(this); }
  4052. //
  4053. // Connection-oriented data transfer
  4054. //
  4055. OTResult Snd(void* buf, OTByteCount nbytes, OTFlags flags)
  4056. { return OTSnd(this, buf, nbytes, flags); }
  4057. OTResult Rcv(void* buf, OTByteCount nbytes, OTFlags* flagP)
  4058. { return OTRcv(this, buf, nbytes, flagP); }
  4059. //
  4060. // Non-connection-oriented data transfer
  4061. //
  4062. OSStatus SndUData(TUnitData* udata)
  4063. { return OTSndUData(this, udata); }
  4064. OSStatus RcvUData(TUnitData* udata, OTFlags* flagP)
  4065. { return OTRcvUData(this, udata, flagP); }
  4066. OSStatus RcvUDErr(TUDErr* uderr)
  4067. { return OTRcvUDErr(this, uderr); }
  4068. #if CALL_NOT_IN_CARBON
  4069. //
  4070. // Connection-oriented transactions
  4071. //
  4072. OSStatus SndRequest(TRequest* req, OTFlags reqFlags)
  4073. { return OTSndRequest(this, req, reqFlags); }
  4074. OSStatus RcvReply(TReply* reply, OTFlags* replyFlags)
  4075. { return OTRcvReply(this, reply, replyFlags); }
  4076. OSStatus SndReply(TReply* reply, OTFlags flags)
  4077. { return OTSndReply(this, reply, flags); }
  4078. OSStatus RcvRequest(TRequest* req, OTFlags* flags)
  4079. { return OTRcvRequest(this, req, flags); }
  4080. OSStatus CancelRequest(OTSequence seq)
  4081. { return OTCancelRequest(this, seq); }
  4082. OSStatus CancelReply(OTSequence seq)
  4083. { return OTCancelReply(this, seq); }
  4084. //
  4085. // Non-connection-oriented transactions
  4086. //
  4087. OSStatus SndURequest(TUnitRequest* req, OTFlags reqFlags)
  4088. { return OTSndURequest(this, req, reqFlags); }
  4089. OSStatus RcvUReply(TUnitReply* reply, OTFlags* replyFlags)
  4090. { return OTRcvUReply(this, reply, replyFlags); }
  4091. OSStatus SndUReply(TUnitReply* reply, OTFlags flags)
  4092. { return OTSndUReply(this, reply, flags); }
  4093. OSStatus RcvURequest(TUnitRequest* req, OTFlags* flags)
  4094. { return OTRcvURequest(this, req, flags); }
  4095. OSStatus CancelURequest(OTSequence seq)
  4096. { return OTCancelURequest(this, seq); }
  4097. OSStatus CancelUReply(OTSequence seq)
  4098. { return OTCancelUReply(this, seq); }
  4099. #endif
  4100. //
  4101. // Miscellaneous functions
  4102. //
  4103. OTResult CountDataBytes(OTByteCount* countPtr)
  4104. { return OTCountDataBytes(this, countPtr); }
  4105. };
  4106. /* -------------------------------------------------------------------------
  4107. CLASS TMapper
  4108. This class is the interface to naming protocols.
  4109. ------------------------------------------------------------------------- */
  4110. class TMapper : public TProvider
  4111. {
  4112. public:
  4113. OSStatus RegisterName(TRegisterRequest* req, TRegisterReply* reply)
  4114. { return OTRegisterName(this, req, reply); }
  4115. OSStatus DeleteName(TNetbuf* name)
  4116. { return OTDeleteName(this, name); }
  4117. OSStatus DeleteName(OTNameID theID)
  4118. { return OTDeleteNameByID(this, theID); }
  4119. OSStatus LookupName(TLookupRequest* req, TLookupReply* reply)
  4120. { return OTLookupName(this, req, reply); }
  4121. };
  4122. #endif /* !OTKERNEL */
  4123. extern "C" { // resume C definitions
  4124. #endif /* __cplusplus */
  4125. #if defined(__MWERKS__) && TARGET_CPU_68K
  4126. #pragma pop
  4127. #endif
  4128. #if PRAGMA_STRUCT_ALIGN
  4129. #pragma options align=reset
  4130. #elif PRAGMA_STRUCT_PACKPUSH
  4131. #pragma pack(pop)
  4132. #elif PRAGMA_STRUCT_PACK
  4133. #pragma pack()
  4134. #endif
  4135. #ifdef PRAGMA_IMPORT_OFF
  4136. #pragma import off
  4137. #elif PRAGMA_IMPORT
  4138. #pragma import reset
  4139. #endif
  4140. #ifdef __cplusplus
  4141. }
  4142. #endif
  4143. #endif /* __OPENTRANSPORT__ */