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.

118 lines
3.0 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1994.
  5. //
  6. // File: statmon.hxx
  7. //
  8. // Contents: Tracks CI failure status.
  9. //
  10. // Classes: CCiStatusMonitor
  11. //
  12. // Functions:
  13. //
  14. // History: 3-20-96 srikants Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #pragma once
  18. class CEventItem;
  19. class CCiStatusMonitor
  20. {
  21. public:
  22. enum EMessageType { eCorrupt,
  23. eCIStarted,
  24. eInitFailed,
  25. eCiRemoved,
  26. eCiError,
  27. ePropStoreRecoveryStart,
  28. ePropStoreRecoveryEnd,
  29. ePropStoreError,
  30. ePropStoreRecoveryError };
  31. CCiStatusMonitor( WCHAR const * wcsCatDir )
  32. : _wcsCatDir( wcsCatDir ), _status(STATUS_SUCCESS),
  33. _fDontLog(FALSE), _fPropStoreOk(TRUE), _fLowDiskSpace(FALSE)
  34. {
  35. }
  36. BOOL IsCorrupt( ) const
  37. {
  38. return CI_CORRUPT_DATABASE == _status ||
  39. CI_CORRUPT_CATALOG == _status;
  40. }
  41. void SetStatus( NTSTATUS status ) { _status = status; }
  42. NTSTATUS GetStatus() const { return _status; }
  43. void ReportInitFailure();
  44. void ReportFailure( NTSTATUS status );
  45. void Reset()
  46. {
  47. _status = STATUS_SUCCESS;
  48. _fDontLog = FALSE;
  49. }
  50. BOOL IsOk() const { return STATUS_SUCCESS == _status; }
  51. void LogEvent( EMessageType eType, DWORD status = STATUS_SUCCESS,
  52. ULONG val = 0 );
  53. void ReportPropStoreError()
  54. {
  55. if ( _fPropStoreOk )
  56. {
  57. LogEvent( ePropStoreError );
  58. _fPropStoreOk = FALSE;
  59. }
  60. }
  61. void ReportPropStoreRecoveryError( ULONG cInconsistencies )
  62. {
  63. LogEvent( ePropStoreRecoveryError, 0, cInconsistencies );
  64. }
  65. void ReportPropStoreRecoveryStart()
  66. {
  67. LogEvent( ePropStoreRecoveryStart );
  68. }
  69. void ReportPropStoreRecoveryEnd()
  70. {
  71. LogEvent( ePropStoreRecoveryEnd );
  72. }
  73. void ReportCIStarted()
  74. {
  75. LogEvent( eCIStarted );
  76. }
  77. BOOL IsLowOnDisk() const { return _fLowDiskSpace; }
  78. void SetDiskFull() { _fLowDiskSpace = TRUE; }
  79. void ClearLowDiskSpace() { _fLowDiskSpace = FALSE; }
  80. static void ReportPathTooLong( WCHAR const * pwszPath );
  81. private:
  82. const WCHAR * _wcsCatDir; // The catalog directory
  83. NTSTATUS _status; // Last reported status
  84. BOOL _fDontLog; // Set to TRUE if we shouldn't log
  85. // anymore
  86. BOOL _fPropStoreOk; // Indicates if property store is ok
  87. BOOL _fLowDiskSpace; // Indicates if low disk space was
  88. // reported.
  89. };