home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Beta / Quicktime 2.0 Beta.iso / Programming Stuff / Interfaces / Universal Interfaces / DatabaseAccess.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-30  |  13.2 KB  |  393 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        DatabaseAccess.h
  3.  
  4.     Copyright:    © 1984-1993 by Apple Computer, Inc., all rights reserved.
  5.  
  6.     WARNING
  7.     This file was auto generated by the interfacer tool. Modifications
  8.     must be made to the master file.
  9.  
  10. */
  11.  
  12. #ifndef __DATABASEACCESS__
  13. #define __DATABASEACCESS__
  14.  
  15. #ifndef __RESOURCES__
  16. #include <Resources.h>
  17. /*    #include <Types.h>                                            */
  18. /*        #include <ConditionalMacros.h>                            */
  19. /*        #include <MixedMode.h>                                    */
  20. /*            #include <Traps.h>                                    */
  21. /*    #include <Files.h>                                            */
  22. /*        #include <OSUtils.h>                                    */
  23. /*        #include <SegLoad.h>                                    */
  24. #endif
  25.  
  26.  
  27. /* data type codes */
  28.  
  29. #define typeNone 'none'
  30.  
  31. #define typeDate 'date'
  32.  
  33. #define typeTime 'time'
  34.  
  35. #define typeTimeStamp 'tims'
  36.  
  37. #define typeDecimal 'deci'
  38.  
  39. #define typeMoney 'mone'
  40.  
  41. #define typeVChar 'vcha'
  42.  
  43. #define typeVBin 'vbin'
  44.  
  45. #define typeLChar 'lcha'
  46.  
  47. #define typeLBin 'lbin'
  48.  
  49. #define typeDiscard 'disc'
  50.  
  51.  
  52. /* "dummy" types for DBResultsToText */
  53.  
  54. #define typeUnknown 'unkn'
  55.  
  56. #define typeColBreak 'colb'
  57.  
  58. #define typeRowBreak 'rowb'
  59.  
  60.  
  61. /* pass this in to DBGetItem for any data type */
  62.  
  63. #define typeAnyType (DBType)0
  64.  
  65.  
  66. /* infinite timeout value for DBGetItem */
  67.  
  68. enum  {
  69. /* error and status codes */
  70.     rcDBNull                    = -800,
  71.     rcDBValue                    = -801,
  72.     rcDBError                    = -802,
  73.     rcDBBadType                    = -803,
  74.     rcDBBreak                    = -804,
  75.     rcDBExec                    = -805,
  76.     rcDBBadSessID                = -806,
  77.     rcDBBadSessNum                = -807,                            /* bad session number for DBGetConnInfo */
  78.     rcDBBadDDEV                    = -808,                            /* bad ddev specified on DBInit */
  79.     rcDBAsyncNotSupp            = -809,                            /* ddev does not support async calls */
  80.     rcDBBadAsyncPB                = -810,                            /* tried to kill a bad pb */
  81.     rcDBNoHandler                = -811,                            /* no app handler for specified data type */
  82.     rcDBWrongVersion            = -812,                            /* incompatible versions */
  83.     rcDBPackNotInited            = -813,                            /* attempt to call other routine before InitDBPack */
  84. /* messages for status functions for DBStartQuery */
  85.     kDBUpdateWind                = 0,
  86.     kDBAboutToInit                = 1,
  87.     kDBInitComplete                = 2,
  88.     kDBSendComplete                = 3,
  89.     kDBExecComplete                = 4,
  90.     kDBStartQueryComplete        = 5
  91. };
  92.  
  93. enum  {
  94. /* messages for status functions for DBGetQueryResults */
  95.     kDBGetItemComplete            = 6,
  96.     kDBGetQueryResultsComplete    = 7,
  97.     kDBWaitForever                = -1,
  98. /*  flags for DBGetItem  */
  99.     kDBLastColFlag                = 0x0001,
  100.     kDBNullFlag                    = 0x0004
  101. };
  102.  
  103. typedef OSType DBType;
  104.  
  105. typedef struct DBAsyncParamBlockRec DBAsyncParamBlockRec, *DBAsyncParmBlkPtr;
  106.  
  107.  
  108. /*
  109.     DBCompletionProcs cannot be written in or called from a high-level
  110.     language without the help of mixed mode or assembly glue because they 
  111.     use the following parameter-passing convention:
  112.  
  113.     typedef pascal void (*DBCompletionProcPtr)(DBAsyncParmBlkPtr pb);
  114.  
  115.         In:
  116.             =>     pb        A0.L
  117.         Out:
  118.             none
  119. */
  120.  
  121. enum  {
  122.     uppDBCompletionProcInfo        = kRegisterBased|REGISTER_ROUTINE_PARAMETER(1,kRegisterA0,kFourByteCode)
  123. };
  124.  
  125. #if USESROUTINEDESCRIPTORS
  126. typedef pascal void (*DBCompletionProcPtr)(DBAsyncParmBlkPtr pb);
  127.  
  128. typedef UniversalProcPtr DBCompletionUPP;
  129.  
  130. #define CallDBCompletionProc(userRoutine, pb)  \
  131.     CallUniversalProc((UniversalProcPtr)(userRoutine), uppDBCompletionProcInfo, (pb))
  132.  
  133. #define NewDBCompletionProc(userRoutine)  \
  134.     (DBCompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppDBCompletionProcInfo, GetCurrentISA())
  135.  
  136. #else
  137. typedef ProcPtr DBCompletionUPP;
  138.  
  139. #define NewDBCompletionProc(userRoutine)  \
  140.     (DBCompletionUPP)((userRoutine))
  141.  
  142. #endif
  143.  
  144.  
  145. /* structure for asynchronous parameter block */
  146.  
  147. #if defined(powerc) || defined (__powerc)
  148. #pragma options align=mac68k
  149. #endif
  150. struct DBAsyncParamBlockRec {
  151.     DBCompletionUPP                completionProc;                    /* pointer to completion routine */
  152.     OSErr                        result;                            /* result of call */
  153.     long                        userRef;                        /* for application's use */
  154.     long                        ddevRef;                        /* for ddev's use */
  155.     long                        reserved;                        /* for internal use */
  156. };
  157. #if defined(powerc) || defined(__powerc)
  158. #pragma options align=reset
  159. #endif
  160.  
  161.  
  162. /* structure for resource list in QueryRecord */
  163.  
  164. #if defined(powerc) || defined (__powerc)
  165. #pragma options align=mac68k
  166. #endif
  167. struct ResListElem {
  168.     ResType                        theType;                        /* resource type */
  169.     short                        id;                                /* resource id */
  170. };
  171. #if defined(powerc) || defined(__powerc)
  172. #pragma options align=reset
  173. #endif
  174.  
  175. typedef struct ResListElem ResListElem;
  176.  
  177. typedef ResListElem *ResListPtr, **ResListHandle;
  178.  
  179.  
  180. /* structure for query list in QueryRecord */
  181.  
  182. typedef Handle **QueryListHandle;
  183.  
  184. #if defined(powerc) || defined (__powerc)
  185. #pragma options align=mac68k
  186. #endif
  187. struct QueryRecord {
  188.     short                        version;                        /* version */
  189.     short                        id;                                /* id of 'qrsc' this came from */
  190.     Handle                        queryProc;                        /* handle to query def proc */
  191.     Str63                        ddevName;                        /* ddev name */
  192.     Str255                        host;                            /* host name */
  193.     Str255                        user;                            /* user name */
  194.     Str255                        password;                        /* password */
  195.     Str255                        connStr;                        /* connection string */
  196.     short                        currQuery;                        /* index of current query */
  197.     short                        numQueries;                        /* number of queries in list */
  198.     QueryListHandle                queryList;                        /* handle to array of handles to text */
  199.     short                        numRes;                            /* number of resources in list */
  200.     ResListHandle                resList;                        /* handle to array of resource list elements */
  201.     Handle                        dataHandle;                        /* for use by query def proc */
  202.     long                        refCon;                            /* for use by application */
  203. };
  204. #if defined(powerc) || defined(__powerc)
  205. #pragma options align=reset
  206. #endif
  207.  
  208. typedef struct QueryRecord QueryRecord;
  209.  
  210. typedef QueryRecord *QueryPtr, **QueryHandle;
  211.  
  212. typedef pascal OSErr (*DBQueryDefProcPtr)(long *sessID, QueryHandle query);
  213.  
  214. enum {
  215.     uppDBQueryDefProcInfo = kPascalStackBased
  216.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  217.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long*)))
  218.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(QueryHandle)))
  219. };
  220.  
  221. #if USESROUTINEDESCRIPTORS
  222. typedef UniversalProcPtr DBQueryDefUPP;
  223.  
  224. #define CallDBQueryDefProc(userRoutine, sessID, query)        \
  225.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppDBQueryDefProcInfo, (sessID), (query))
  226. #define NewDBQueryDefProc(userRoutine)        \
  227.         (DBQueryDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppDBQueryDefProcInfo, GetCurrentISA())
  228. #else
  229. typedef DBQueryDefProcPtr DBQueryDefUPP;
  230.  
  231. #define CallDBQueryDefProc(userRoutine, sessID, query)        \
  232.         (*(userRoutine))((sessID), (query))
  233. #define NewDBQueryDefProc(userRoutine)        \
  234.         (DBQueryDefUPP)(userRoutine)
  235. #endif
  236.  
  237.  
  238. /* structure of column types array in ResultsRecord */
  239.  
  240. typedef Handle ColTypesHandle;
  241.  
  242.  
  243. /* structure for column info in ResultsRecord */
  244.  
  245. #if defined(powerc) || defined (__powerc)
  246. #pragma options align=mac68k
  247. #endif
  248. struct DBColInfoRecord {
  249.     short                        len;
  250.     short                        places;
  251.     short                        flags;
  252. };
  253. #if defined(powerc) || defined(__powerc)
  254. #pragma options align=reset
  255. #endif
  256.  
  257. typedef struct DBColInfoRecord DBColInfoRecord;
  258.  
  259. typedef Handle ColInfoHandle;
  260.  
  261.  
  262. /* structure of results returned by DBGetResults */
  263.  
  264. #if defined(powerc) || defined (__powerc)
  265. #pragma options align=mac68k
  266. #endif
  267. struct ResultsRecord {
  268.     short                        numRows;                        /* number of rows in result */
  269.     short                        numCols;                        /* number of columns per row */
  270.     ColTypesHandle                colTypes;                        /* data type array */
  271.     Handle                        colData;                        /* actual results */
  272.     ColInfoHandle                colInfo;                        /* DBColInfoRecord array */
  273. };
  274. #if defined(powerc) || defined(__powerc)
  275. #pragma options align=reset
  276. #endif
  277.  
  278. typedef struct ResultsRecord ResultsRecord;
  279.  
  280. typedef pascal Boolean (*DBStatusProcPtr)(short message, OSErr result, short dataLen, short dataPlaces, short dataFlags, DBType dataType, Ptr dataPtr);
  281.  
  282. enum {
  283.     uppDBStatusProcInfo = kPascalStackBased
  284.          | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  285.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  286.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(OSErr)))
  287.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short)))
  288.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short)))
  289.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(short)))
  290.          | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(DBType)))
  291.          | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(Ptr)))
  292. };
  293.  
  294. #if USESROUTINEDESCRIPTORS
  295. typedef UniversalProcPtr DBStatusUPP;
  296.  
  297. #define CallDBStatusProc(userRoutine, message, result, dataLen, dataPlaces, dataFlags, dataType, dataPtr)        \
  298.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppDBStatusProcInfo, (message), (result), (dataLen), (dataPlaces), (dataFlags), (dataType), (dataPtr))
  299. #define NewDBStatusProc(userRoutine)        \
  300.         (DBStatusUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppDBStatusProcInfo, GetCurrentISA())
  301. #else
  302. typedef DBStatusProcPtr DBStatusUPP;
  303.  
  304. #define CallDBStatusProc(userRoutine, message, result, dataLen, dataPlaces, dataFlags, dataType, dataPtr)        \
  305.         (*(userRoutine))((message), (result), (dataLen), (dataPlaces), (dataFlags), (dataType), (dataPtr))
  306. #define NewDBStatusProc(userRoutine)        \
  307.         (DBStatusUPP)(userRoutine)
  308. #endif
  309.  
  310. typedef pascal OSErr (*DBResultHandlerProcPtr)(DBType dataType, short theLen, short thePlaces, short theFlags, Ptr theData, Handle theText);
  311.  
  312. enum {
  313.     uppDBResultHandlerProcInfo = kPascalStackBased
  314.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  315.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(DBType)))
  316.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  317.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short)))
  318.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short)))
  319.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(Ptr)))
  320.          | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(Handle)))
  321. };
  322.  
  323. #if USESROUTINEDESCRIPTORS
  324. typedef UniversalProcPtr DBResultHandlerUPP;
  325.  
  326. #define CallDBResultHandlerProc(userRoutine, dataType, theLen, thePlaces, theFlags, theData, theText)        \
  327.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppDBResultHandlerProcInfo, (dataType), (theLen), (thePlaces), (theFlags), (theData), (theText))
  328. #define NewDBResultHandlerProc(userRoutine)        \
  329.         (DBResultHandlerUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppDBResultHandlerProcInfo, GetCurrentISA())
  330. #else
  331. typedef DBResultHandlerProcPtr DBResultHandlerUPP;
  332.  
  333. #define CallDBResultHandlerProc(userRoutine, dataType, theLen, thePlaces, theFlags, theData, theText)        \
  334.         (*(userRoutine))((dataType), (theLen), (thePlaces), (theFlags), (theData), (theText))
  335. #define NewDBResultHandlerProc(userRoutine)        \
  336.         (DBResultHandlerUPP)(userRoutine)
  337. #endif
  338.  
  339. #ifdef __cplusplus
  340. extern "C" {
  341. #endif
  342.  
  343. extern pascal OSErr InitDBPack(void)
  344.  FIVEWORDINLINE(0x3F3C, 0x0004, 0x303C, 0x0100, 0xA82F);
  345. extern pascal OSErr DBInit(long *sessID, ConstStr63Param ddevName, ConstStr255Param host, ConstStr255Param user, ConstStr255Param passwd, ConstStr255Param connStr, DBAsyncParmBlkPtr asyncPB)
  346.  THREEWORDINLINE(0x303C, 0x0E02, 0xA82F);
  347. extern pascal OSErr DBEnd(long sessID, DBAsyncParmBlkPtr asyncPB)
  348.  THREEWORDINLINE(0x303C, 0x0403, 0xA82F);
  349. extern pascal OSErr DBGetConnInfo(long sessID, short sessNum, long *returnedID, long *version, Str63 ddevName, Str255 host, Str255 user, Str255 network, Str255 connStr, long *start, OSErr *state, DBAsyncParmBlkPtr asyncPB)
  350.  THREEWORDINLINE(0x303C, 0x1704, 0xA82F);
  351. extern pascal OSErr DBGetSessionNum(long sessID, short *sessNum, DBAsyncParmBlkPtr asyncPB)
  352.  THREEWORDINLINE(0x303C, 0x0605, 0xA82F);
  353. extern pascal OSErr DBSend(long sessID, char *text, short len, DBAsyncParmBlkPtr asyncPB)
  354.  THREEWORDINLINE(0x303C, 0x0706, 0xA82F);
  355. extern pascal OSErr DBSendItem(long sessID, DBType dataType, short len, short places, short flags, void *buffer, DBAsyncParmBlkPtr asyncPB)
  356.  THREEWORDINLINE(0x303C, 0x0B07, 0xA82F);
  357. extern pascal OSErr DBExec(long sessID, DBAsyncParmBlkPtr asyncPB)
  358.  THREEWORDINLINE(0x303C, 0x0408, 0xA82F);
  359. extern pascal OSErr DBState(long sessID, DBAsyncParmBlkPtr asyncPB)
  360.  THREEWORDINLINE(0x303C, 0x0409, 0xA82F);
  361. extern pascal OSErr DBGetErr(long sessID, long *err1, long *err2, Str255 item1, Str255 item2, Str255 errorMsg, DBAsyncParmBlkPtr asyncPB)
  362.  THREEWORDINLINE(0x303C, 0x0E0A, 0xA82F);
  363. extern pascal OSErr DBBreak(long sessID, Boolean abort, DBAsyncParmBlkPtr asyncPB)
  364.  THREEWORDINLINE(0x303C, 0x050B, 0xA82F);
  365. extern pascal OSErr DBGetItem(long sessID, long timeout, DBType *dataType, short *len, short *places, short *flags, void *buffer, DBAsyncParmBlkPtr asyncPB)
  366.  THREEWORDINLINE(0x303C, 0x100C, 0xA82F);
  367. extern pascal OSErr DBUnGetItem(long sessID, DBAsyncParmBlkPtr asyncPB)
  368.  THREEWORDINLINE(0x303C, 0x040D, 0xA82F);
  369. extern pascal OSErr DBKill(DBAsyncParmBlkPtr asyncPB)
  370.  THREEWORDINLINE(0x303C, 0x020E, 0xA82F);
  371. extern pascal OSErr DBGetNewQuery(short queryID, QueryHandle *query)
  372.  THREEWORDINLINE(0x303C, 0x030F, 0xA82F);
  373. extern pascal OSErr DBDisposeQuery(QueryHandle query)
  374.  THREEWORDINLINE(0x303C, 0x0210, 0xA82F);
  375. extern pascal OSErr DBStartQuery(long *sessID, QueryHandle query, DBStatusUPP statusProc, DBAsyncParmBlkPtr asyncPB)
  376.  THREEWORDINLINE(0x303C, 0x0811, 0xA82F);
  377. extern pascal OSErr DBGetQueryResults(long sessID, ResultsRecord *results, long timeout, DBStatusUPP statusProc, DBAsyncParmBlkPtr asyncPB)
  378.  THREEWORDINLINE(0x303C, 0x0A12, 0xA82F);
  379. extern pascal OSErr DBResultsToText(ResultsRecord *results, Handle *theText)
  380.  THREEWORDINLINE(0x303C, 0x0413, 0xA82F);
  381. extern pascal OSErr DBInstallResultHandler(DBType dataType, DBResultHandlerUPP theHandler, Boolean isSysHandler)
  382.  THREEWORDINLINE(0x303C, 0x0514, 0xA82F);
  383. extern pascal OSErr DBRemoveResultHandler(DBType dataType)
  384.  THREEWORDINLINE(0x303C, 0x0215, 0xA82F);
  385. extern pascal OSErr DBGetResultHandler(DBType dataType, DBResultHandlerUPP *theHandler, Boolean getSysHandler)
  386.  THREEWORDINLINE(0x303C, 0x0516, 0xA82F);
  387. #ifdef __cplusplus
  388. }
  389. #endif
  390.  
  391. #endif
  392.  
  393.