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.

108 lines
4.1 KiB

  1. // Ruler
  2. // 1 2 3 4 5 6 7 8
  3. //345678901234567890123456789012345678901234567890123456789012345678901234567890
  4. /********************************************************************/
  5. /* */
  6. /* The standard layout. */
  7. /* */
  8. /* The standard layout for 'cpp' files in this code is as */
  9. /* follows: */
  10. /* */
  11. /* 1. Include files. */
  12. /* 2. Constants local to the class. */
  13. /* 3. Data structures local to the class. */
  14. /* 4. Data initializations. */
  15. /* 5. Static functions. */
  16. /* 6. Class functions. */
  17. /* */
  18. /* The constructor is typically the first function, class */
  19. /* member functions appear in alphabetical order with the */
  20. /* destructor appearing at the end of the file. Any section */
  21. /* or function this is not required is simply omitted. */
  22. /* */
  23. /********************************************************************/
  24. #include "LibraryPCH.hpp"
  25. #include "Global.hpp"
  26. /********************************************************************/
  27. /* */
  28. /* Debug printing. */
  29. /* */
  30. /* We sometimes need to print message during debugging. We */
  31. /* do this using the following 'printf' like function. */
  32. /* */
  33. /********************************************************************/
  34. VOID DebugPrint( CONST CHAR *Format,... )
  35. {
  36. AUTO CHAR Buffer[ DebugBufferSize ];
  37. #ifdef ENABLE_DEBUG_FILE
  38. STATIC FILE *DebugFile = NULL;
  39. #endif
  40. //
  41. // Start of variable arguments.
  42. //
  43. va_list Arguments;
  44. va_start(Arguments, Format);
  45. //
  46. // Format the string to be printed.
  47. //
  48. (VOID) _vsnprintf( Buffer,(DebugBufferSize-1),Format,Arguments );
  49. //
  50. // Force null termination.
  51. //
  52. Buffer[ (DebugBufferSize-1) ] = '\0';
  53. #ifdef ENABLE_DEBUG_FILE
  54. //
  55. // Write to the debug file.
  56. //
  57. if ( DebugFile == NULL )
  58. {
  59. if ( (DebugFile = fopen( "C:\\DebugFile.TXT","a" )) == NULL )
  60. { Failure( "Debug file could not be opened" ); }
  61. }
  62. fputs( Buffer,DebugFile );
  63. fflush( DebugFile );
  64. #else
  65. //
  66. // Write the string to the debug file.
  67. //
  68. OutputDebugString( Buffer );
  69. #endif
  70. //
  71. // End of variable arguments.
  72. //
  73. va_end( Arguments );
  74. }
  75. /********************************************************************/
  76. /* */
  77. /* Software failure. */
  78. /* */
  79. /* We know that when this function is called the application */
  80. /* has failed so we simply try to cleanly exit in the vain */
  81. /* hope that the failure can be caught and corrected. */
  82. /* */
  83. /********************************************************************/
  84. VOID Failure( char *Message )
  85. {
  86. #ifdef DISABLE_STRUCTURED_EXCEPTIONS
  87. throw ((FAULT) Message);
  88. #else
  89. RaiseException( 1,0,1,((CONST DWORD*) Message) );
  90. #endif
  91. }