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.

121 lines
2.4 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. All rights reserved.
  4. Module Name:
  5. ntstatus.cxx
  6. Abstract:
  7. auto log
  8. Author:
  9. Larry Zhu (LZhu) December 6, 2001
  10. Revision History:
  11. --*/
  12. // #include "precomp.hxx"
  13. // #pragma hdrstop
  14. #include "ntstatus.hxx"
  15. #ifdef DBG
  16. #if 0
  17. #define STATUS_SEVERITY_WARNING 0x2
  18. #define STATUS_SEVERITY_SUCCESS 0x0
  19. #define STATUS_SEVERITY_INFORMATIONAL 0x1
  20. #define STATUS_SEVERITY_ERROR 0x3
  21. #endif 0
  22. PCTSTR
  23. NtStatusServerity(
  24. IN NTSTATUS Status
  25. )
  26. {
  27. PCTSTR pcszSev = NULL;
  28. /* Here is the layout of the message ID:
  29. 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  30. 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  31. +---+-+-+-----------------------+-------------------------------+
  32. |Sev|C|R| Facility | Code |
  33. +---+-+-+-----------------------+-------------------------------+
  34. where
  35. Sev - is the severity code
  36. C - is the Customer code flag
  37. R - is a reserved bit
  38. Facility - is the facility code
  39. Code - is the facility's status code
  40. */
  41. ULONG dwSev = ((ULONG) Status) >> 30;
  42. switch (dwSev)
  43. {
  44. case STATUS_SEVERITY_WARNING:
  45. pcszSev = TEXT("WARNING"); break;
  46. case STATUS_SEVERITY_SUCCESS:
  47. pcszSev = TEXT("SUCCESS"); break;
  48. case STATUS_SEVERITY_INFORMATIONAL:
  49. pcszSev = TEXT("INFORMATIONAL"); break;
  50. case STATUS_SEVERITY_ERROR:
  51. pcszSev = TEXT("ERROR"); break;
  52. default:
  53. pcszSev = TEXT("Unknown!"); break;
  54. }
  55. return pcszSev;
  56. }
  57. /********************************************************************
  58. TNtStatus members
  59. ********************************************************************/
  60. TNtStatus::
  61. TNtStatus(
  62. IN NTSTATUS Status
  63. ) : TStatusDerived<NTSTATUS>(Status)
  64. {
  65. }
  66. TNtStatus::
  67. ~TNtStatus(
  68. VOID
  69. )
  70. {
  71. }
  72. bool
  73. TNtStatus::
  74. IsErrorSevereEnough(
  75. VOID
  76. ) const
  77. {
  78. NTSTATUS Status = GetTStatusBase();
  79. return NT_ERROR(Status) || NT_WARNING(Status) || NT_INFORMATION(Status);
  80. }
  81. PCTSTR
  82. TNtStatus::
  83. GetErrorServerityDescription(
  84. VOID
  85. ) const
  86. {
  87. NTSTATUS Status = GetTStatusBase();
  88. return NtStatusServerity(Status);
  89. }
  90. #endif // DBG