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

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       DatabaseAccess.h
  3.  
  4.      Contains:   Database Access Manager Interfaces.
  5.  
  6.      Version:    Technology: System 7.5
  7.                  Release:    QuickTime 6.0.2
  8.  
  9.      Copyright:  (c) 1989-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 __DATABASEACCESS__
  18. #define __DATABASEACCESS__
  19. #ifndef __RESOURCES__
  20. #include "Resources.h"
  21. #endif
  22. #if PRAGMA_ONCE
  23. #pragma once
  24. #endif
  25. #ifdef __cplusplus
  26. extern "C" {
  27. #endif
  28. #if PRAGMA_IMPORT
  29. #pragma import on
  30. #endif
  31. #if PRAGMA_STRUCT_ALIGN
  32.     #pragma options align=mac68k
  33. #elif PRAGMA_STRUCT_PACKPUSH
  34.     #pragma pack(push, 2)
  35. #elif PRAGMA_STRUCT_PACK
  36.     #pragma pack(2)
  37. #endif
  38. /* data type codes */
  39. enum {
  40.     typeNone                    = FOUR_CHAR_CODE('none'),
  41.     typeDate                    = FOUR_CHAR_CODE('date'),
  42.     typeTime                    = FOUR_CHAR_CODE('time'),
  43.     typeTimeStamp               = FOUR_CHAR_CODE('tims'),
  44.     typeDecimal                 = FOUR_CHAR_CODE('deci'),
  45.     typeMoney                   = FOUR_CHAR_CODE('mone'),
  46.     typeVChar                   = FOUR_CHAR_CODE('vcha'),
  47.     typeVBin                    = FOUR_CHAR_CODE('vbin'),
  48.     typeLChar                   = FOUR_CHAR_CODE('lcha'),
  49.     typeLBin                    = FOUR_CHAR_CODE('lbin'),
  50.     typeDiscard                 = FOUR_CHAR_CODE('disc'),       /* "dummy" types for DBResultsToText */
  51.     typeUnknown                 = FOUR_CHAR_CODE('unkn'),
  52.     typeColBreak                = FOUR_CHAR_CODE('colb'),
  53.     typeRowBreak                = FOUR_CHAR_CODE('rowb'),       /* pass this in to DBGetItem for any data type */
  54.     typeAnyType                 = 0
  55. };
  56. /* infinite timeout value for DBGetItem */
  57. enum {
  58.                                                                 /* messages for status functions for DBStartQuery */
  59.     kDBUpdateWind               = 0,
  60.     kDBAboutToInit              = 1,
  61.     kDBInitComplete             = 2,
  62.     kDBSendComplete             = 3,
  63.     kDBExecComplete             = 4,
  64.     kDBStartQueryComplete       = 5
  65. };
  66. enum {
  67.                                                                 /* messages for status functions for DBGetQueryResults */
  68.     kDBGetItemComplete          = 6,
  69.     kDBGetQueryResultsComplete  = 7,
  70.     kDBWaitForever              = -1
  71. };
  72. enum {
  73.                                                                 /*  flags for DBGetItem  */
  74.     kDBLastColFlag              = 0x0001,
  75.     kDBNullFlag                 = 0x0004
  76. };
  77. typedef OSType                          DBType;
  78. typedef struct DBAsyncParamBlockRec     DBAsyncParamBlockRec;
  79. typedef DBAsyncParamBlockRec *          DBAsyncParmBlkPtr;
  80. typedef CALLBACK_API( void , DBCompletionProcPtr )(DBAsyncParmBlkPtr pb);
  81. /*
  82.     WARNING: DBCompletionProcPtr uses register based parameters under classic 68k
  83.              and cannot be written in a high-level language without 
  84.              the help of mixed mode or assembly glue.
  85. */
  86. typedef REGISTER_UPP_TYPE(DBCompletionProcPtr)                  DBCompletionUPP;
  87. /* structure for asynchronous parameter block */
  88. struct DBAsyncParamBlockRec {
  89.     DBCompletionUPP                 completionProc;             /* pointer to completion routine */
  90.     OSErr                           result;                     /* result of call */
  91.     long                            userRef;                    /* for application's use */
  92.     long                            ddevRef;                    /* for ddev's use */
  93.     long                            reserved;                   /* for internal use */
  94. };
  95. /* structure for resource list in QueryRecord */
  96. struct ResListElem {
  97.     ResType                         theType;                    /* resource type */
  98.     short                           id;                         /* resource id */
  99. };
  100. typedef struct ResListElem              ResListElem;
  101. typedef ResListElem *                   ResListPtr;
  102. typedef ResListPtr *                    ResListHandle;
  103. /* structure for query list in QueryRecord */
  104. typedef Handle                          QueryArray[256];
  105. typedef Handle *                        QueryListPtr;
  106. typedef QueryListPtr *                  QueryListHandle;
  107. struct QueryRecord {
  108.     short                           version;                    /* version */
  109.     short                           id;                         /* id of 'qrsc' this came from */
  110.     Handle                          queryProc;                  /* handle to query def proc */
  111.     Str63                           ddevName;                   /* ddev name */
  112.     Str255                          host;                       /* host name */
  113.     Str255                          user;                       /* user name */
  114.     Str255                          password;                   /* password */
  115.     Str255                          connStr;                    /* connection string */
  116.     short                           currQuery;                  /* index of current query */
  117.     short                           numQueries;                 /* number of queries in list */
  118.     QueryListHandle                 queryList;                  /* handle to array of handles to text */
  119.     short                           numRes;                     /* number of resources in list */
  120.     ResListHandle                   resList;                    /* handle to array of resource list elements */
  121.     Handle                          dataHandle;                 /* for use by query def proc */
  122.     long                            refCon;                     /* for use by application */
  123. };
  124. typedef struct QueryRecord              QueryRecord;
  125. typedef QueryRecord *                   QueryPtr;
  126. typedef QueryPtr *                      QueryHandle;
  127. /* structure of column types array in ResultsRecord */
  128. typedef DBType                          ColTypesArray[256];
  129. typedef Handle                          ColTypesHandle;
  130. /* structure for column info in ResultsRecord */
  131. struct DBColInfoRecord {
  132.     short                           len;
  133.     short                           places;
  134.     short                           flags;
  135. };
  136. typedef struct DBColInfoRecord          DBColInfoRecord;
  137. typedef DBColInfoRecord                 ColInfoArray[256];
  138. typedef Handle                          ColInfoHandle;
  139. /* structure of results returned by DBGetResults */
  140. struct ResultsRecord {
  141.     short                           numRows;                    /* number of rows in result */
  142.     short                           numCols;                    /* number of columns per row */
  143.     ColTypesHandle                  colTypes;                   /* data type array */
  144.     Handle                          colData;                    /* actual results */
  145.     ColInfoHandle                   colInfo;                    /* DBColInfoRecord array */
  146. };
  147. typedef struct ResultsRecord            ResultsRecord;
  148. enum {
  149.                                                                 /* messages sent to a 'ddev'*/
  150.     kDBInit                     = 0,
  151.     kDBEnd                      = 1,
  152.     kDBGetConnInfo              = 2,
  153.     kDBGetSessionNum            = 3,
  154.     kDBSend                     = 4,
  155.     kDBSendItem                 = 5,
  156.     kDBExec                     = 6,
  157.     kDBState                    = 7,
  158.     kDBGetErr                   = 8,
  159.     kDBBreak                    = 9,
  160.     kDBGetItem                  = 10,
  161.     kDBUngetItem                = 11,
  162.     kDBKill                     = 12,
  163.     kDBOpen                     = 100,
  164.     kDBClose                    = 101,
  165.     kDBIdle                     = 102
  166. };
  167. typedef CALLBACK_API( OSErr , DBQueryDefProcPtr )(long *sessID, QueryHandle query);
  168. typedef CALLBACK_API( Boolean , DBStatusProcPtr )(short message, OSErr result, short dataLen, short dataPlaces, short dataFlags, DBType dataType, Ptr dataPtr);
  169. typedef CALLBACK_API( OSErr , DBResultHandlerProcPtr )(DBType dataType, short theLen, short thePlaces, short theFlags, Ptr theData, Handle theText);
  170. typedef STACK_UPP_TYPE(DBQueryDefProcPtr)                       DBQueryDefUPP;
  171. typedef STACK_UPP_TYPE(DBStatusProcPtr)                         DBStatusUPP;
  172. typedef STACK_UPP_TYPE(DBResultHandlerProcPtr)                  DBResultHandlerUPP;
  173. #if OPAQUE_UPP_TYPES
  174. #if CALL_NOT_IN_CARBON
  175.     EXTERN_API(DBCompletionUPP)
  176.     NewDBCompletionUPP             (DBCompletionProcPtr     userRoutine);
  177.     EXTERN_API(DBQueryDefUPP)
  178.     NewDBQueryDefUPP               (DBQueryDefProcPtr       userRoutine);
  179.     EXTERN_API(DBStatusUPP)
  180.     NewDBStatusUPP                 (DBStatusProcPtr         userRoutine);
  181.     EXTERN_API(DBResultHandlerUPP)
  182.     NewDBResultHandlerUPP          (DBResultHandlerProcPtr  userRoutine);
  183.     EXTERN_API(void)
  184.     DisposeDBCompletionUPP         (DBCompletionUPP         userUPP);
  185.     EXTERN_API(void)
  186.     DisposeDBQueryDefUPP           (DBQueryDefUPP           userUPP);
  187.     EXTERN_API(void)
  188.     DisposeDBStatusUPP             (DBStatusUPP             userUPP);
  189.     EXTERN_API(void)
  190.     DisposeDBResultHandlerUPP      (DBResultHandlerUPP      userUPP);
  191.     EXTERN_API(void)
  192.     InvokeDBCompletionUPP          (DBAsyncParmBlkPtr       pb,
  193.                                     DBCompletionUPP         userUPP);
  194.     EXTERN_API(OSErr)
  195.     InvokeDBQueryDefUPP            (long *                  sessID,
  196.                                     QueryHandle             query,
  197.                                     DBQueryDefUPP           userUPP);
  198.     EXTERN_API(Boolean)
  199.     InvokeDBStatusUPP              (short                   message,
  200.                                     OSErr                   result,
  201.                                     short                   dataLen,
  202.                                     short                   dataPlaces,
  203.                                     short                   dataFlags,
  204.                                     DBType                  dataType,
  205.                                     Ptr                     dataPtr,
  206.                                     DBStatusUPP             userUPP);
  207.     EXTERN_API(OSErr)
  208.     InvokeDBResultHandlerUPP       (DBType                  dataType,
  209.                                     short                   theLen,
  210.                                     short                   thePlaces,
  211.                                     short                   theFlags,
  212.                                     Ptr                     theData,
  213.                                     Handle                  theText,
  214.                                     DBResultHandlerUPP      userUPP);
  215. #endif  /* CALL_NOT_IN_CARBON */
  216. #else
  217.     enum { uppDBCompletionProcInfo = 0x0000B802 };                  /* register no_return_value Func(4_bytes:A1) */
  218.     enum { uppDBQueryDefProcInfo = 0x000003E0 };                    /* pascal 2_bytes Func(4_bytes, 4_bytes) */
  219.     enum { uppDBStatusProcInfo = 0x000FAA90 };                      /* pascal 1_byte Func(2_bytes, 2_bytes, 2_bytes, 2_bytes, 2_bytes, 4_bytes, 4_bytes) */
  220.     enum { uppDBResultHandlerProcInfo = 0x0003EAE0 };               /* pascal 2_bytes Func(4_bytes, 2_bytes, 2_bytes, 2_bytes, 4_bytes, 4_bytes) */
  221.     #define NewDBCompletionUPP(userRoutine)                         (DBCompletionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppDBCompletionProcInfo, GetCurrentArchitecture())
  222.     #define NewDBQueryDefUPP(userRoutine)                           (DBQueryDefUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppDBQueryDefProcInfo, GetCurrentArchitecture())
  223.     #define NewDBStatusUPP(userRoutine)                             (DBStatusUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppDBStatusProcInfo, GetCurrentArchitecture())
  224.     #define NewDBResultHandlerUPP(userRoutine)                      (DBResultHandlerUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppDBResultHandlerProcInfo, GetCurrentArchitecture())
  225.     #define DisposeDBCompletionUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  226.     #define DisposeDBQueryDefUPP(userUPP)                           DisposeRoutineDescriptor(userUPP)
  227.     #define DisposeDBStatusUPP(userUPP)                             DisposeRoutineDescriptor(userUPP)
  228.     #define DisposeDBResultHandlerUPP(userUPP)                      DisposeRoutineDescriptor(userUPP)
  229.     #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  230.     #pragma parameter InvokeDBCompletionUPP(__A1, __A0)
  231.     void InvokeDBCompletionUPP(DBAsyncParmBlkPtr pb, DBCompletionUPP userUPP) = 0x4E90;
  232.     #else
  233.         #define InvokeDBCompletionUPP(pb, userUPP)                      CALL_ONE_PARAMETER_UPP((userUPP), uppDBCompletionProcInfo, (pb))
  234.     #endif
  235.     #define InvokeDBQueryDefUPP(sessID, query, userUPP)             (OSErr)CALL_TWO_PARAMETER_UPP((userUPP), uppDBQueryDefProcInfo, (sessID), (query))
  236.     #define InvokeDBStatusUPP(message, result, dataLen, dataPlaces, dataFlags, dataType, dataPtr, userUPP)  (Boolean)CALL_SEVEN_PARAMETER_UPP((userUPP), uppDBStatusProcInfo, (message), (result), (dataLen), (dataPlaces), (dataFlags), (dataType), (dataPtr))
  237.     #define InvokeDBResultHandlerUPP(dataType, theLen, thePlaces, theFlags, theData, theText, userUPP)  (OSErr)CALL_SIX_PARAMETER_UPP((userUPP), uppDBResultHandlerProcInfo, (dataType), (theLen), (thePlaces), (theFlags), (theData), (theText))
  238. #endif
  239. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  240. #define NewDBCompletionProc(userRoutine)                        NewDBCompletionUPP(userRoutine)
  241. #define NewDBQueryDefProc(userRoutine)                          NewDBQueryDefUPP(userRoutine)
  242. #define NewDBStatusProc(userRoutine)                            NewDBStatusUPP(userRoutine)
  243. #define NewDBResultHandlerProc(userRoutine)                     NewDBResultHandlerUPP(userRoutine)
  244. #define CallDBCompletionProc(userRoutine, pb)                   InvokeDBCompletionUPP(pb, userRoutine)
  245. #define CallDBQueryDefProc(userRoutine, sessID, query)          InvokeDBQueryDefUPP(sessID, query, userRoutine)
  246. #define CallDBStatusProc(userRoutine, message, result, dataLen, dataPlaces, dataFlags, dataType, dataPtr) InvokeDBStatusUPP(message, result, dataLen, dataPlaces, dataFlags, dataType, dataPtr, userRoutine)
  247. #define CallDBResultHandlerProc(userRoutine, dataType, theLen, thePlaces, theFlags, theData, theText) InvokeDBResultHandlerUPP(dataType, theLen, thePlaces, theFlags, theData, theText, userRoutine)
  248. #if CALL_NOT_IN_CARBON
  249. EXTERN_API( OSErr )
  250. InitDBPack                      (void)                                                      FIVEWORDINLINE(0x3F3C, 0x0004, 0x303C, 0x0100, 0xA82F);
  251. EXTERN_API( OSErr )
  252. DBInit                          (long *                 sessID,
  253.                                  ConstStr63Param        ddevName,
  254.                                  ConstStr255Param       host,
  255.                                  ConstStr255Param       user,
  256.                                  ConstStr255Param       passwd,
  257.                                  ConstStr255Param       connStr,
  258.                                  DBAsyncParmBlkPtr      asyncPB)                            THREEWORDINLINE(0x303C, 0x0E02, 0xA82F);
  259. EXTERN_API( OSErr )
  260. DBEnd                           (long                   sessID,
  261.                                  DBAsyncParmBlkPtr      asyncPB)                            THREEWORDINLINE(0x303C, 0x0403, 0xA82F);
  262. EXTERN_API( OSErr )
  263. DBGetConnInfo                   (long                   sessID,
  264.                                  short                  sessNum,
  265.                                  long *                 returnedID,
  266.                                  long *                 version,
  267.                                  Str63                  ddevName,
  268.                                  Str255                 host,
  269.                                  Str255                 user,
  270.                                  Str255                 network,
  271.                                  Str255                 connStr,
  272.                                  long *                 start,
  273.                                  OSErr *                state,
  274.                                  DBAsyncParmBlkPtr      asyncPB)                            THREEWORDINLINE(0x303C, 0x1704, 0xA82F);
  275. EXTERN_API( OSErr )
  276. DBGetSessionNum                 (long                   sessID,
  277.                                  short *                sessNum,
  278.                                  DBAsyncParmBlkPtr      asyncPB)                            THREEWORDINLINE(0x303C, 0x0605, 0xA82F);
  279. EXTERN_API( OSErr )
  280. DBSend                          (long                   sessID,
  281.                                  Ptr                    text,
  282.                                  short                  len,
  283.                                  DBAsyncParmBlkPtr      asyncPB)                            THREEWORDINLINE(0x303C, 0x0706, 0xA82F);
  284. EXTERN_API( OSErr )
  285. DBSendItem                      (long                   sessID,
  286.                                  DBType                 dataType,
  287.                                  short                  len,
  288.                                  short                  places,
  289.                                  short                  flags,
  290.                                  void *                 buffer,
  291.                                  DBAsyncParmBlkPtr      asyncPB)                            THREEWORDINLINE(0x303C, 0x0B07, 0xA82F);
  292. EXTERN_API( OSErr )
  293. DBExec                          (long                   sessID,
  294.                                  DBAsyncParmBlkPtr      asyncPB)                            THREEWORDINLINE(0x303C, 0x0408, 0xA82F);
  295. EXTERN_API( OSErr )
  296. DBState                         (long                   sessID,
  297.                                  DBAsyncParmBlkPtr      asyncPB)                            THREEWORDINLINE(0x303C, 0x0409, 0xA82F);
  298. EXTERN_API( OSErr )
  299. DBGetErr                        (long                   sessID,
  300.                                  long *                 err1,
  301.                                  long *                 err2,
  302.                                  Str255                 item1,
  303.                                  Str255                 item2,
  304.                                  Str255                 errorMsg,
  305.                                  DBAsyncParmBlkPtr      asyncPB)                            THREEWORDINLINE(0x303C, 0x0E0A, 0xA82F);
  306. EXTERN_API( OSErr )
  307. DBBreak                         (long                   sessID,
  308.                                  Boolean                abort,
  309.                                  DBAsyncParmBlkPtr      asyncPB)                            THREEWORDINLINE(0x303C, 0x050B, 0xA82F);
  310. EXTERN_API( OSErr )
  311. DBGetItem                       (long                   sessID,
  312.                                  long                   timeout,
  313.                                  DBType *               dataType,
  314.                                  short *                len,
  315.                                  short *                places,
  316.                                  short *                flags,
  317.                                  void *                 buffer,
  318.                                  DBAsyncParmBlkPtr      asyncPB)                            THREEWORDINLINE(0x303C, 0x100C, 0xA82F);
  319. EXTERN_API( OSErr )
  320. DBUnGetItem                     (long                   sessID,
  321.                                  DBAsyncParmBlkPtr      asyncPB)                            THREEWORDINLINE(0x303C, 0x040D, 0xA82F);
  322. EXTERN_API( OSErr )
  323. DBKill                          (DBAsyncParmBlkPtr      asyncPB)                            THREEWORDINLINE(0x303C, 0x020E, 0xA82F);
  324. EXTERN_API( OSErr )
  325. DBGetNewQuery                   (short                  queryID,
  326.                                  QueryHandle *          query)                              THREEWORDINLINE(0x303C, 0x030F, 0xA82F);
  327. EXTERN_API( OSErr )
  328. DBDisposeQuery                  (QueryHandle            query)                              THREEWORDINLINE(0x303C, 0x0210, 0xA82F);
  329. EXTERN_API( OSErr )
  330. DBStartQuery                    (long *                 sessID,
  331.                                  QueryHandle            query,
  332.                                  DBStatusUPP            statusProc,
  333.                                  DBAsyncParmBlkPtr      asyncPB)                            THREEWORDINLINE(0x303C, 0x0811, 0xA82F);
  334. EXTERN_API( OSErr )
  335. DBGetQueryResults               (long                   sessID,
  336.                                  ResultsRecord *        results,
  337.                                  long                   timeout,
  338.                                  DBStatusUPP            statusProc,
  339.                                  DBAsyncParmBlkPtr      asyncPB)                            THREEWORDINLINE(0x303C, 0x0A12, 0xA82F);
  340. EXTERN_API( OSErr )
  341. DBResultsToText                 (ResultsRecord *        results,
  342.                                  Handle *               theText)                            THREEWORDINLINE(0x303C, 0x0413, 0xA82F);
  343. EXTERN_API( OSErr )
  344. DBInstallResultHandler          (DBType                 dataType,
  345.                                  DBResultHandlerUPP     theHandler,
  346.                                  Boolean                isSysHandler)                       THREEWORDINLINE(0x303C, 0x0514, 0xA82F);
  347. EXTERN_API( OSErr )
  348. DBRemoveResultHandler           (DBType                 dataType)                           THREEWORDINLINE(0x303C, 0x0215, 0xA82F);
  349. EXTERN_API( OSErr )
  350. DBGetResultHandler              (DBType                 dataType,
  351.                                  DBResultHandlerUPP *   theHandler,
  352.                                  Boolean                getSysHandler)                      THREEWORDINLINE(0x303C, 0x0516, 0xA82F);
  353. EXTERN_API( OSErr )
  354. DBIdle                          (void)                                                      THREEWORDINLINE(0x303C, 0x00FF, 0xA82F);
  355. #endif  /* CALL_NOT_IN_CARBON */
  356. #if PRAGMA_STRUCT_ALIGN
  357.     #pragma options align=reset
  358. #elif PRAGMA_STRUCT_PACKPUSH
  359.     #pragma pack(pop)
  360. #elif PRAGMA_STRUCT_PACK
  361.     #pragma pack()
  362. #endif
  363. #ifdef PRAGMA_IMPORT_OFF
  364. #pragma import off
  365. #elif PRAGMA_IMPORT
  366. #pragma import reset
  367. #endif
  368. #ifdef __cplusplus
  369. }
  370. #endif
  371. #endif /* __DATABASEACCESS__ */