Leaked source code of windows server 2003
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.

100 lines
3.3 KiB

  1. extern DAB *pdabGlobalMin;
  2. extern DAB *pdabGlobalMax;
  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. VOID DBCloseDatabaseByDbid( PIB *ppib, DBID dbid );
  7. BOOL FDatabaseInUse( DBID dbid );
  8. ERR ErrDBCreateDatabase( PIB *ppib, CHAR *szDatabaseName, CHAR *szConnect, DBID *pdbid, CPG cpgPrimary, ULONG grbit, SIGNATURE *psignDb );
  9. ERR ErrDBSetLastPage( PIB *ppib, DBID dbid );
  10. ERR ErrDBSetupAttachedDB(VOID);
  11. VOID DBISetHeaderAfterAttach( DBFILEHDR *pdbfilehdr, LGPOS lgposAttach, DBID dbid, BOOL fKeepBackupInfo );
  12. ERR ErrDBReadHeaderCheckConsistency( CHAR *szFileName, DBID dbid );
  13. ERR ErrDABCloseAllDBs( PIB *ppib );
  14. #define SetOpenDatabaseFlag( ppib, dbid ) \
  15. { \
  16. ((ppib)->rgcdbOpen[dbid]++); \
  17. Assert( ((ppib)->rgcdbOpen[dbid] > 0 ) ); \
  18. }
  19. #define ResetOpenDatabaseFlag( ppib, dbid ) \
  20. { \
  21. Assert( ((ppib)->rgcdbOpen[dbid] > 0 ) ); \
  22. ((ppib)->rgcdbOpen[dbid]--); \
  23. }
  24. #define FUserOpenedDatabase( ppib, dbid ) \
  25. ((ppib)->rgcdbOpen[dbid] > 0)
  26. #define FLastOpen( ppib, dbid ) \
  27. ((ppib)->rgcdbOpen[dbid] == 1)
  28. #define FUserDbid( dbid ) \
  29. (dbid > dbidTemp && dbid < dbidMax)
  30. #define ErrDBCheck( ppib, dbid ) \
  31. ( FUserOpenedDatabase( ppib, dbid ) ? JET_errSuccess : JET_errInvalidDatabaseId )
  32. #define CheckDBID( ppib, dbid ) \
  33. Assert( FUserOpenedDatabase( ppib, dbid ) )
  34. /* Database Attribute Block
  35. /**/
  36. typedef struct _dab
  37. {
  38. PIB *ppib; /* thread that opens this DAB */
  39. DAB *pdabNext; /* next DAB opened by the same ppib */
  40. JET_GRBIT grbit; /* database open mode */
  41. DBID dbid; /* database id */
  42. } DAB;
  43. #define ErrDABCheck( ppibT, pdab ) \
  44. ( ( ((DAB *)pdab) >= pdabGlobalMin && \
  45. ((DAB *)pdab) < pdabGlobalMax && \
  46. (((ULONG_PTR)pdab - (ULONG_PTR)pdabGlobalMin) % sizeof(DAB) == 0) && \
  47. ((DAB *)pdab)->ppib == (ppibT) ) ? \
  48. JET_errSuccess : JET_errInvalidDatabaseId )
  49. // Database info in DATABASES tree
  50. typedef struct {
  51. BYTE bDbid;
  52. BYTE bLoggable;
  53. /* rgchDatabaseName must be last field in structure
  54. /**/
  55. CHAR rgchDatabaseName[1];
  56. } DBA;
  57. ERR ErrDBStoreDBPath( CHAR *szDBName, CHAR **pszDBPath );
  58. /* bogus dbid uniqifying code
  59. /**/
  60. #define vdbidNil NULL
  61. typedef DAB * VDBID;
  62. #ifdef DISPATCHING
  63. #define VdbidMEMAlloc() (VDBID)PbMEMAlloc(iresDAB)
  64. #ifdef DEBUG /* Debug check for illegal reuse of freed vdbid */
  65. #define ReleaseVDbid( vdbid ) { MEMRelease( iresDAB, (BYTE *) vdbid ); vdbid = vdbidNil; }
  66. #else
  67. #define ReleaseVDbid( vdbid ) { MEMRelease( iresDAB, (BYTE *) vdbid ); }
  68. #endif
  69. #define DbidOfVDbid( vdbid ) ( ( (VDBID) vdbid )->dbid )
  70. #define GrbitOfVDbid( vdbid ) ( ( (VDBID) vdbid )->grbit )
  71. #define FVDbidReadOnly( vdbid ) ( ( (VDBID) vdbid )->grbit & JET_bitDbReadOnly )
  72. #define VDbidCheckUpdatable( vdbid ) \
  73. ( FVDbidReadOnly( vdbid ) ? ErrERRCheck( JET_errPermissionDenied ) : JET_errSuccess )
  74. #else
  75. #define DbidOfVDbid( vdbid ) (vdbid)
  76. #define VdbidMEMAlloc()
  77. #define ReleaseVDbid( vdbid )
  78. #define GrbitOfVDbid( vdbid )
  79. #define FVDbidReadOnly( vdbid )
  80. #define VDbidCheckUpdatable( vdbid )
  81. #endif