Connections.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:24k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       Connections.h
  3.  
  4.      Contains:   Communications Toolbox Connection Manager Interfaces.
  5.  
  6.      Version:    Technology: System 7.5
  7.                  Release:    QuickTime 6.0.2
  8.  
  9.      Copyright:  (c) 1988-2001 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:      For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __CONNECTIONS__
  18. #define __CONNECTIONS__
  19. #ifndef __CONDITIONALMACROS__
  20. #include "ConditionalMacros.h"
  21. #endif
  22. #ifndef __MACTYPES__
  23. #include "MacTypes.h"
  24. #endif
  25. #ifndef __MIXEDMODE__
  26. #include "MixedMode.h"
  27. #endif
  28. #ifndef __DIALOGS__
  29. #include "Dialogs.h"
  30. #endif
  31. #if PRAGMA_ONCE
  32. #pragma once
  33. #endif
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37. #if PRAGMA_IMPORT
  38. #pragma import on
  39. #endif
  40. #if PRAGMA_STRUCT_ALIGN
  41.     #pragma options align=mac68k
  42. #elif PRAGMA_STRUCT_PACKPUSH
  43.     #pragma pack(push, 2)
  44. #elif PRAGMA_STRUCT_PACK
  45.     #pragma pack(2)
  46. #endif
  47. #if CALL_NOT_IN_CARBON
  48. enum {
  49.     curCMVersion                = 2                             /* current Connection Manager version*/
  50. };
  51. enum {
  52.     curConnEnvRecVers           = 0                             /*    current Connection Manager Environment Record version*/
  53. };
  54. enum {
  55.                                                                 /* CMErr */
  56.     cmGenericError              = -1,
  57.     cmNoErr                     = 0,
  58.     cmRejected                  = 1,
  59.     cmFailed                    = 2,
  60.     cmTimeOut                   = 3,
  61.     cmNotOpen                   = 4,
  62.     cmNotClosed                 = 5,
  63.     cmNoRequestPending          = 6,
  64.     cmNotSupported              = 7,
  65.     cmNoTools                   = 8,
  66.     cmUserCancel                = 9,
  67.     cmUnknownError              = 11
  68. };
  69. typedef OSErr                           CMErr;
  70. enum {
  71.     cmData                      = 1L << 0,
  72.     cmCntl                      = 1L << 1,
  73.     cmAttn                      = 1L << 2,
  74.     cmDataNoTimeout             = 1L << 4,
  75.     cmCntlNoTimeout             = 1L << 5,
  76.     cmAttnNoTimeout             = 1L << 6,
  77.     cmDataClean                 = 1L << 8,
  78.     cmCntlClean                 = 1L << 9,
  79.     cmAttnClean                 = 1L << 10,                     /*       Only for CMRecFlags (not CMChannel) in the rest of this enum  */
  80.     cmNoMenus                   = 1L << 16,
  81.     cmQuiet                     = 1L << 17,
  82.     cmConfigChanged             = 1L << 18
  83. };
  84. /* CMRecFlags and CMChannel     */
  85. /*      Low word of CMRecFlags is same as CMChannel */
  86. typedef long                            CMRecFlags;
  87. typedef short                           CMChannel;
  88. enum {
  89.     cmStatusOpening             = 1L << 0,
  90.     cmStatusOpen                = 1L << 1,
  91.     cmStatusClosing             = 1L << 2,
  92.     cmStatusDataAvail           = 1L << 3,
  93.     cmStatusCntlAvail           = 1L << 4,
  94.     cmStatusAttnAvail           = 1L << 5,
  95.     cmStatusDRPend              = 1L << 6,                      /* data read pending  */
  96.     cmStatusDWPend              = 1L << 7,                      /* data write pending */
  97.     cmStatusCRPend              = 1L << 8,                      /* cntl read pending  */
  98.     cmStatusCWPend              = 1L << 9,                      /* cntl write pending */
  99.     cmStatusARPend              = 1L << 10,                     /* attn read pending  */
  100.     cmStatusAWPend              = 1L << 11,                     /* attn write pending */
  101.     cmStatusBreakPend           = 1L << 12,
  102.     cmStatusListenPend          = 1L << 13,
  103.     cmStatusIncomingCallPresent = 1L << 14,
  104.     cmStatusReserved0           = 1L << 15
  105. };
  106. typedef unsigned long                   CMStatFlags;
  107. enum {
  108.     cmDataIn                    = 0,
  109.     cmDataOut                   = 1,
  110.     cmCntlIn                    = 2,
  111.     cmCntlOut                   = 3,
  112.     cmAttnIn                    = 4,
  113.     cmAttnOut                   = 5,
  114.     cmRsrvIn                    = 6,
  115.     cmRsrvOut                   = 7
  116. };
  117. typedef unsigned short                  CMBufFields;
  118. typedef Ptr                             CMBuffers[8];
  119. typedef long                            CMBufferSizes[8];
  120. typedef const long *                    ConstCMBufferSizesParam;
  121. enum {
  122.     cmSearchSevenBit            = 1L << 0
  123. };
  124. typedef unsigned short                  CMSearchFlags;
  125. enum {
  126.     cmFlagsEOM                  = 1L << 0
  127. };
  128. typedef unsigned short                  CMFlags;
  129. struct ConnEnvironRec {
  130.     short                           version;
  131.     long                            baudRate;
  132.     short                           dataBits;
  133.     CMChannel                       channels;
  134.     Boolean                         swFlowControl;
  135.     Boolean                         hwFlowControl;
  136.     CMFlags                         flags;
  137. };
  138. typedef struct ConnEnvironRec           ConnEnvironRec;
  139. typedef ConnEnvironRec *                ConnEnvironRecPtr;
  140. typedef struct ConnRecord               ConnRecord;
  141. typedef ConnRecord *                    ConnPtr;
  142. typedef ConnPtr *                       ConnHandle;
  143. typedef CALLBACK_API( long , ConnectionToolDefProcPtr )(ConnHandle hConn, short msg, long p1, long p2, long p3);
  144. typedef CALLBACK_API( void , ConnectionSearchCallBackProcPtr )(ConnHandle hConn, Ptr matchPtr, long refNum);
  145. typedef CALLBACK_API( void , ConnectionCompletionProcPtr )(ConnHandle hConn);
  146. typedef CALLBACK_API( void , ConnectionChooseIdleProcPtr )(void );
  147. typedef STACK_UPP_TYPE(ConnectionToolDefProcPtr)                ConnectionToolDefUPP;
  148. typedef STACK_UPP_TYPE(ConnectionSearchCallBackProcPtr)         ConnectionSearchCallBackUPP;
  149. typedef STACK_UPP_TYPE(ConnectionCompletionProcPtr)             ConnectionCompletionUPP;
  150. typedef STACK_UPP_TYPE(ConnectionChooseIdleProcPtr)             ConnectionChooseIdleUPP;
  151. struct ConnRecord {
  152.     short                           procID;
  153.     CMRecFlags                      flags;
  154.     CMErr                           errCode;
  155.     long                            refCon;
  156.     long                            userData;
  157.     ConnectionToolDefUPP            defProc;
  158.     Ptr                             config;
  159.     Ptr                             oldConfig;
  160.     long                            asyncEOM;
  161.     long                            reserved1;
  162.     long                            reserved2;
  163.     Ptr                             cmPrivate;
  164.     CMBuffers                       bufferArray;
  165.     CMBufferSizes                   bufSizes;
  166.     long                            mluField;
  167.     CMBufferSizes                   asyncCount;
  168. };
  169. enum {
  170.                                                                 /* CMIOPB constants and structure */
  171.     cmIOPBQType                 = 10,
  172.     cmIOPBversion               = 0
  173. };
  174. struct CMIOPB {
  175.     QElemPtr                        qLink;
  176.     short                           qType;                      /* cmIOPBQType */
  177.     ConnHandle                      hConn;
  178.     Ptr                             theBuffer;
  179.     long                            count;
  180.     CMFlags                         flags;
  181.     ConnectionCompletionUPP         userCompletion;
  182.     long                            timeout;
  183.     CMErr                           errCode;
  184.     CMChannel                       channel;
  185.     long                            asyncEOM;
  186.     long                            reserved1;
  187.     short                           reserved2;
  188.     short                           version;                    /* cmIOPBversion */
  189.     long                            refCon;                     /* for application */
  190.     long                            toolData1;                  /* for tool */
  191.     long                            toolData2;                  /* for tool */
  192. };
  193. typedef struct CMIOPB                   CMIOPB;
  194. typedef CMIOPB *                        CMIOPBPtr;
  195. #if OPAQUE_UPP_TYPES
  196. #if CALL_NOT_IN_CARBON
  197.     EXTERN_API(ConnectionToolDefUPP)
  198.     NewConnectionToolDefUPP        (ConnectionToolDefProcPtr userRoutine);
  199.     EXTERN_API(ConnectionSearchCallBackUPP)
  200.     NewConnectionSearchCallBackUPP    (ConnectionSearchCallBackProcPtr userRoutine);
  201.     EXTERN_API(ConnectionCompletionUPP)
  202.     NewConnectionCompletionUPP     (ConnectionCompletionProcPtr userRoutine);
  203.     EXTERN_API(ConnectionChooseIdleUPP)
  204.     NewConnectionChooseIdleUPP     (ConnectionChooseIdleProcPtr userRoutine);
  205.     EXTERN_API(void)
  206.     DisposeConnectionToolDefUPP    (ConnectionToolDefUPP    userUPP);
  207.     EXTERN_API(void)
  208.     DisposeConnectionSearchCallBackUPP    (ConnectionSearchCallBackUPP userUPP);
  209.     EXTERN_API(void)
  210.     DisposeConnectionCompletionUPP    (ConnectionCompletionUPP userUPP);
  211.     EXTERN_API(void)
  212.     DisposeConnectionChooseIdleUPP    (ConnectionChooseIdleUPP userUPP);
  213.     EXTERN_API(long)
  214.     InvokeConnectionToolDefUPP     (ConnHandle              hConn,
  215.                                     short                   msg,
  216.                                     long                    p1,
  217.                                     long                    p2,
  218.                                     long                    p3,
  219.                                     ConnectionToolDefUPP    userUPP);
  220.     EXTERN_API(void)
  221.     InvokeConnectionSearchCallBackUPP    (ConnHandle        hConn,
  222.                                     Ptr                     matchPtr,
  223.                                     long                    refNum,
  224.                                     ConnectionSearchCallBackUPP userUPP);
  225.     EXTERN_API(void)
  226.     InvokeConnectionCompletionUPP    (ConnHandle            hConn,
  227.                                     ConnectionCompletionUPP userUPP);
  228.     EXTERN_API(void)
  229.     InvokeConnectionChooseIdleUPP    (ConnectionChooseIdleUPP userUPP);
  230. #endif  /* CALL_NOT_IN_CARBON */
  231. #else
  232.     enum { uppConnectionToolDefProcInfo = 0x0000FEF0 };             /* pascal 4_bytes Func(4_bytes, 2_bytes, 4_bytes, 4_bytes, 4_bytes) */
  233.     enum { uppConnectionSearchCallBackProcInfo = 0x00000FC0 };      /* pascal no_return_value Func(4_bytes, 4_bytes, 4_bytes) */
  234.     enum { uppConnectionCompletionProcInfo = 0x000000C0 };          /* pascal no_return_value Func(4_bytes) */
  235.     enum { uppConnectionChooseIdleProcInfo = 0x00000000 };          /* pascal no_return_value Func() */
  236.     #define NewConnectionToolDefUPP(userRoutine)                    (ConnectionToolDefUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppConnectionToolDefProcInfo, GetCurrentArchitecture())
  237.     #define NewConnectionSearchCallBackUPP(userRoutine)             (ConnectionSearchCallBackUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppConnectionSearchCallBackProcInfo, GetCurrentArchitecture())
  238.     #define NewConnectionCompletionUPP(userRoutine)                 (ConnectionCompletionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppConnectionCompletionProcInfo, GetCurrentArchitecture())
  239.     #define NewConnectionChooseIdleUPP(userRoutine)                 (ConnectionChooseIdleUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppConnectionChooseIdleProcInfo, GetCurrentArchitecture())
  240.     #define DisposeConnectionToolDefUPP(userUPP)                    DisposeRoutineDescriptor(userUPP)
  241.     #define DisposeConnectionSearchCallBackUPP(userUPP)             DisposeRoutineDescriptor(userUPP)
  242.     #define DisposeConnectionCompletionUPP(userUPP)                 DisposeRoutineDescriptor(userUPP)
  243.     #define DisposeConnectionChooseIdleUPP(userUPP)                 DisposeRoutineDescriptor(userUPP)
  244.     #define InvokeConnectionToolDefUPP(hConn, msg, p1, p2, p3, userUPP)  (long)CALL_FIVE_PARAMETER_UPP((userUPP), uppConnectionToolDefProcInfo, (hConn), (msg), (p1), (p2), (p3))
  245.     #define InvokeConnectionSearchCallBackUPP(hConn, matchPtr, refNum, userUPP)  CALL_THREE_PARAMETER_UPP((userUPP), uppConnectionSearchCallBackProcInfo, (hConn), (matchPtr), (refNum))
  246.     #define InvokeConnectionCompletionUPP(hConn, userUPP)           CALL_ONE_PARAMETER_UPP((userUPP), uppConnectionCompletionProcInfo, (hConn))
  247.     #define InvokeConnectionChooseIdleUPP(userUPP)                  CALL_ZERO_PARAMETER_UPP((userUPP), uppConnectionChooseIdleProcInfo)
  248. #endif
  249. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  250. #define NewConnectionToolDefProc(userRoutine)                   NewConnectionToolDefUPP(userRoutine)
  251. #define NewConnectionSearchCallBackProc(userRoutine)            NewConnectionSearchCallBackUPP(userRoutine)
  252. #define NewConnectionCompletionProc(userRoutine)                NewConnectionCompletionUPP(userRoutine)
  253. #define NewConnectionChooseIdleProc(userRoutine)                NewConnectionChooseIdleUPP(userRoutine)
  254. #define CallConnectionToolDefProc(userRoutine, hConn, msg, p1, p2, p3) InvokeConnectionToolDefUPP(hConn, msg, p1, p2, p3, userRoutine)
  255. #define CallConnectionSearchCallBackProc(userRoutine, hConn, matchPtr, refNum) InvokeConnectionSearchCallBackUPP(hConn, matchPtr, refNum, userRoutine)
  256. #define CallConnectionCompletionProc(userRoutine, hConn)        InvokeConnectionCompletionUPP(hConn, userRoutine)
  257. #define CallConnectionChooseIdleProc(userRoutine)               InvokeConnectionChooseIdleUPP(userRoutine)
  258. #if CALL_NOT_IN_CARBON
  259. EXTERN_API( CMErr )
  260. InitCM                          (void);
  261. EXTERN_API( Handle )
  262. CMGetVersion                    (ConnHandle             hConn);
  263. EXTERN_API( short )
  264. CMGetCMVersion                  (void);
  265. #endif  /* CALL_NOT_IN_CARBON */
  266. #if CALL_NOT_IN_CARBON
  267. EXTERN_API( ConnHandle )
  268. CMNew                           (short                  procID,
  269.                                  CMRecFlags             flags,
  270.                                  ConstCMBufferSizesParam  desiredSizes,
  271.                                  long                   refCon,
  272.                                  long                   userData);
  273. #endif  /* CALL_NOT_IN_CARBON */
  274. #if CALL_NOT_IN_CARBON
  275. EXTERN_API( void )
  276. CMDispose                       (ConnHandle             hConn);
  277. EXTERN_API( CMErr )
  278. CMListen                        (ConnHandle             hConn,
  279.                                  Boolean                async,
  280.                                  ConnectionCompletionUPP  completor,
  281.                                  long                   timeout);
  282. EXTERN_API( CMErr )
  283. CMAccept                        (ConnHandle             hConn,
  284.                                  Boolean                accept);
  285. EXTERN_API( CMErr )
  286. CMOpen                          (ConnHandle             hConn,
  287.                                  Boolean                async,
  288.                                  ConnectionCompletionUPP  completor,
  289.                                  long                   timeout);
  290. EXTERN_API( CMErr )
  291. CMClose                         (ConnHandle             hConn,
  292.                                  Boolean                async,
  293.                                  ConnectionCompletionUPP  completor,
  294.                                  long                   timeout,
  295.                                  Boolean                now);
  296. EXTERN_API( CMErr )
  297. CMAbort                         (ConnHandle             hConn);
  298. EXTERN_API( CMErr )
  299. CMStatus                        (ConnHandle             hConn,
  300.                                  CMBufferSizes          sizes,
  301.                                  CMStatFlags *          flags);
  302. EXTERN_API( void )
  303. CMIdle                          (ConnHandle             hConn);
  304. EXTERN_API( void )
  305. CMReset                         (ConnHandle             hConn);
  306. EXTERN_API( void )
  307. CMBreak                         (ConnHandle             hConn,
  308.                                  long                   duration,
  309.                                  Boolean                async,
  310.                                  ConnectionCompletionUPP  completor);
  311. EXTERN_API( CMErr )
  312. CMRead                          (ConnHandle             hConn,
  313.                                  void *                 theBuffer,
  314.                                  long *                 toRead,
  315.                                  CMChannel              theChannel,
  316.                                  Boolean                async,
  317.                                  ConnectionCompletionUPP  completor,
  318.                                  long                   timeout,
  319.                                  CMFlags *              flags);
  320. EXTERN_API( CMErr )
  321. CMWrite                         (ConnHandle             hConn,
  322.                                  const void *           theBuffer,
  323.                                  long *                 toWrite,
  324.                                  CMChannel              theChannel,
  325.                                  Boolean                async,
  326.                                  ConnectionCompletionUPP  completor,
  327.                                  long                   timeout,
  328.                                  CMFlags                flags);
  329. EXTERN_API( CMErr )
  330. CMIOKill                        (ConnHandle             hConn,
  331.                                  short                  which);
  332. EXTERN_API( void )
  333. CMActivate                      (ConnHandle             hConn,
  334.                                  Boolean                activate);
  335. EXTERN_API( void )
  336. CMResume                        (ConnHandle             hConn,
  337.                                  Boolean                resume);
  338. EXTERN_API( Boolean )
  339. CMMenu                          (ConnHandle             hConn,
  340.                                  short                  menuID,
  341.                                  short                  item);
  342. EXTERN_API( Boolean )
  343. CMValidate                      (ConnHandle             hConn);
  344. EXTERN_API( void )
  345. CMDefault                       (Ptr *                  theConfig,
  346.                                  short                  procID,
  347.                                  Boolean                allocate);
  348. EXTERN_API( Handle )
  349. CMSetupPreflight                (short                  procID,
  350.                                  long *                 magicCookie);
  351. EXTERN_API( Boolean )
  352. CMSetupFilter                   (short                  procID,
  353.                                  const void *           theConfig,
  354.                                  short                  count,
  355.                                  DialogPtr              theDialog,
  356.                                  EventRecord *          theEvent,
  357.                                  short *                theItem,
  358.                                  long *                 magicCookie);
  359. EXTERN_API( void )
  360. CMSetupSetup                    (short                  procID,
  361.                                  const void *           theConfig,
  362.                                  short                  count,
  363.                                  DialogPtr              theDialog,
  364.                                  long *                 magicCookie);
  365. EXTERN_API( void )
  366. CMSetupItem                     (short                  procID,
  367.                                  const void *           theConfig,
  368.                                  short                  count,
  369.                                  DialogPtr              theDialog,
  370.                                  short *                theItem,
  371.                                  long *                 magicCookie);
  372. EXTERN_API( void )
  373. CMSetupXCleanup                 (short                  procID,
  374.                                  const void *           theConfig,
  375.                                  short                  count,
  376.                                  DialogPtr              theDialog,
  377.                                  Boolean                OKed,
  378.                                  long *                 magicCookie);
  379. EXTERN_API( void )
  380. CMSetupPostflight               (short                  procID);
  381. EXTERN_API( Ptr )
  382. CMGetConfig                     (ConnHandle             hConn);
  383. EXTERN_API( short )
  384. CMSetConfig                     (ConnHandle             hConn,
  385.                                  const void *           thePtr);
  386. EXTERN_API( OSErr )
  387. CMIntlToEnglish                 (ConnHandle             hConn,
  388.                                  const void *           inputPtr,
  389.                                  Ptr *                  outputPtr,
  390.                                  short                  language);
  391. EXTERN_API( OSErr )
  392. CMEnglishToIntl                 (ConnHandle             hConn,
  393.                                  const void *           inputPtr,
  394.                                  Ptr *                  outputPtr,
  395.                                  short                  language);
  396. EXTERN_API( long )
  397. CMAddSearch                     (ConnHandle             hConn,
  398.                                  ConstStr255Param       theString,
  399.                                  CMSearchFlags          flags,
  400.                                  ConnectionSearchCallBackUPP  callBack);
  401. EXTERN_API( void )
  402. CMRemoveSearch                  (ConnHandle             hConn,
  403.                                  long                   refnum);
  404. EXTERN_API( void )
  405. CMClearSearch                   (ConnHandle             hConn);
  406. EXTERN_API( CMErr )
  407. CMGetConnEnvirons               (ConnHandle             hConn,
  408.                                  ConnEnvironRec *       theEnvirons);
  409. EXTERN_API( short )
  410. CMChoose                        (ConnHandle *           hConn,
  411.                                  Point                  where,
  412.                                  ConnectionChooseIdleUPP  idle);
  413. EXTERN_API( void )
  414. CMEvent                         (ConnHandle             hConn,
  415.                                  const EventRecord *    theEvent);
  416. EXTERN_API( void )
  417. CMGetToolName                   (short                  procID,
  418.                                  Str255                 name);
  419. EXTERN_API( short )
  420. CMGetProcID                     (ConstStr255Param       name);
  421. EXTERN_API( void )
  422. CMSetRefCon                     (ConnHandle             hConn,
  423.                                  long                   refCon);
  424. EXTERN_API( long )
  425. CMGetRefCon                     (ConnHandle             hConn);
  426. EXTERN_API( long )
  427. CMGetUserData                   (ConnHandle             hConn);
  428. EXTERN_API( void )
  429. CMSetUserData                   (ConnHandle             hConn,
  430.                                  long                   userData);
  431. EXTERN_API( void )
  432. CMGetErrorString                (ConnHandle             hConn,
  433.                                  short                  id,
  434.                                  Str255                 errMsg);
  435. EXTERN_API( CMErr )
  436. CMNewIOPB                       (ConnHandle             hConn,
  437.                                  CMIOPBPtr *            theIOPB);
  438. EXTERN_API( CMErr )
  439. CMDisposeIOPB                   (ConnHandle             hConn,
  440.                                  CMIOPBPtr              theIOPB);
  441. EXTERN_API( CMErr )
  442. CMPBRead                        (ConnHandle             hConn,
  443.                                  CMIOPBPtr              theIOPB,
  444.                                  Boolean                async);
  445. EXTERN_API( CMErr )
  446. CMPBWrite                       (ConnHandle             hConn,
  447.                                  CMIOPBPtr              theIOPB,
  448.                                  Boolean                async);
  449. EXTERN_API( CMErr )
  450. CMPBIOKill                      (ConnHandle             hConn,
  451.                                  CMIOPBPtr              theIOPB);
  452. #endif  /* CALL_NOT_IN_CARBON */
  453. #endif  /* CALL_NOT_IN_CARBON */
  454. #if PRAGMA_STRUCT_ALIGN
  455.     #pragma options align=reset
  456. #elif PRAGMA_STRUCT_PACKPUSH
  457.     #pragma pack(pop)
  458. #elif PRAGMA_STRUCT_PACK
  459.     #pragma pack()
  460. #endif
  461. #ifdef PRAGMA_IMPORT_OFF
  462. #pragma import off
  463. #elif PRAGMA_IMPORT
  464. #pragma import reset
  465. #endif
  466. #ifdef __cplusplus
  467. }
  468. #endif
  469. #endif /* __CONNECTIONS__ */