Source code of Windows XP (NT5)
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.

97 lines
2.9 KiB

  1. //============== DAE: OS/2 Database Access Engine ===================
  2. //============== dbapi.h: Database API ===================
  3. ERR ErrDBOpenDatabase( PIB *ppib, CHAR *szDatabaseName, DBID *pdbid, ULONG grbit );
  4. ERR ErrDBCloseDatabase( PIB *ppib, DBID dbid, ULONG grbit );
  5. ERR ErrDBOpenDatabaseByDbid( PIB *ppib, DBID dbid );
  6. ERR ErrDBCloseDatabaseByDbid( PIB *ppib, DBID dbid );
  7. BOOL FDatabaseInUse( DBID dbid );
  8. ERR ErrDBCreateDatabase( PIB *ppib, CHAR *szDatabaseName, CHAR *szConnect, DBID *pdbid, ULONG grbit );
  9. ERR ErrDABCloseAllDBs( PIB *ppib );
  10. #define SetOpenDatabaseFlag( ppib, dbid ) \
  11. { \
  12. ((ppib)->rgcdbOpen[dbid]++); \
  13. Assert( ((ppib)->rgcdbOpen[dbid] > 0 ) ); \
  14. }
  15. #define ResetOpenDatabaseFlag( ppib, dbid ) \
  16. { \
  17. Assert( ((ppib)->rgcdbOpen[dbid] > 0 ) ); \
  18. ((ppib)->rgcdbOpen[dbid]--); \
  19. }
  20. #define FUserOpenedDatabase( ppib, dbid ) \
  21. ((ppib)->rgcdbOpen[dbid] > 0)
  22. #define FLastOpen( ppib, dbid ) \
  23. ((ppib)->rgcdbOpen[dbid] == 1)
  24. #define FUserDbid( dbid ) \
  25. (dbid > dbidSystemDatabase && dbid < dbidUserMax)
  26. #define FSysTabDatabase( dbid ) \
  27. (dbid >= dbidSystemDatabase && dbid < dbidUserMax)
  28. #define CheckDBID( ppib, dbid ) \
  29. Assert( FUserOpenedDatabase( ppib, dbid ) )
  30. /* Database Attribute Block
  31. /**/
  32. typedef struct _dab
  33. {
  34. PIB *ppib; /* thread that opens this DAB */
  35. DAB *pdabNext; /* next DAB opened by the same ppib */
  36. JET_GRBIT grbit; /* database open mode */
  37. DBID dbid; /* database id */
  38. } DAB;
  39. #pragma pack(1)
  40. /* database root node data -- in-disk
  41. /**/
  42. typedef struct _dbroot
  43. {
  44. ULONG ulMagic;
  45. ULONG ulVersion;
  46. ULONG ulDBTime;
  47. USHORT usFlags;
  48. } DBROOT;
  49. #pragma pack()
  50. /* Database is loggable
  51. /**/
  52. #define dbrootfLoggable (1 << 0)
  53. ERR ErrDBAccessDatabaseRoot( DBID dbid, SSIB *pssib, DBROOT **ppdbroot );
  54. ERR ErrDBUpdateDatabaseRoot( DBID dbid);
  55. ERR ErrDBStoreDBPath( CHAR *szDBName, CHAR **pszDBPath );
  56. /* bogus dbid uniqifying code
  57. /**/
  58. #define vdbidNil NULL
  59. typedef DAB * VDBID;
  60. #ifdef DISPATCHING
  61. #define VdbidMEMAlloc() (VDBID)PbMEMAlloc(iresDAB)
  62. #ifdef DEBUG /* Debug check for illegal reuse of freed vdbid */
  63. #define ReleaseVDbid( vdbid ) { MEMRelease( iresDAB, (BYTE *) vdbid ); vdbid = vdbidNil; }
  64. #else
  65. #define ReleaseVDbid( vdbid ) { MEMRelease( iresDAB, (BYTE *) vdbid ); }
  66. #endif
  67. #define DbidOfVDbid( vdbid ) ( ( (VDBID) vdbid )->dbid )
  68. #define GrbitOfVDbid( vdbid ) ( ( (VDBID) vdbid )->grbit )
  69. #define FVDbidReadOnly( vdbid ) ( ( (VDBID) vdbid )->grbit & JET_bitDbReadOnly )
  70. #define VDbidCheckUpdatable( vdbid ) \
  71. ( FVDbidReadOnly( vdbid ) ? JET_errPermissionDenied : JET_errSuccess ) \
  72. #else
  73. #define DbidOfVDbid( vdbid ) (vdbid)
  74. #define VdbidMEMAlloc()
  75. #define ReleaseVDbid( vdbid )
  76. #define GrbitOfVDbid( vdbid )
  77. #define FVDbidReadOnly( vdbid )
  78. #define VDbidCheckUpdatable( vdbid )
  79. #endif