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.

111 lines
1.8 KiB

  1. #include <windows.h>
  2. #include "debugout.h"
  3. INT DebugLevel = 0;
  4. BOOL DebugFile = FALSE;
  5. #if DEBUG
  6. VOID PERROR (LPTSTR format, ...)
  7. {
  8. static TCHAR buf[256];
  9. HANDLE hf;
  10. DWORD dwWritten;
  11. va_list vaMark;
  12. if (DebugLevel <= 0)
  13. return;
  14. va_start(vaMark, format);
  15. _vsntprintf(buf, 256, format, vaMark);
  16. va_end(vaMark);
  17. OutputDebugString(buf);
  18. if (!DebugFile)
  19. return;
  20. hf = CreateFile (TEXT("c:\\clipsrv.out"),
  21. GENERIC_WRITE,
  22. 0,
  23. NULL,
  24. OPEN_ALWAYS,
  25. FILE_ATTRIBUTE_NORMAL,
  26. NULL);
  27. if (hf != INVALID_HANDLE_VALUE)
  28. {
  29. SetFilePointer(hf, 0, NULL, FILE_END);
  30. WriteFile(hf, buf, lstrlen(buf), &dwWritten, NULL);
  31. CloseHandle(hf);
  32. }
  33. }
  34. #else
  35. VOID PERROR (LPTSTR format, ...)
  36. {
  37. }
  38. #endif
  39. #ifdef DEBUG
  40. VOID PINFO (LPTSTR format, ...)
  41. {
  42. static TCHAR buf[256];
  43. HANDLE hf;
  44. DWORD dwWritten;
  45. va_list vaMark;
  46. if (DebugLevel <= 1)
  47. return;
  48. va_start(vaMark, format);
  49. _vsntprintf(buf, 256, format, vaMark);
  50. va_end(vaMark);
  51. OutputDebugString(buf);
  52. if (!DebugFile)
  53. return;
  54. hf = CreateFile (TEXT("c:\\clipsrv.out"),
  55. GENERIC_WRITE,
  56. 0,
  57. NULL,
  58. OPEN_ALWAYS,
  59. FILE_ATTRIBUTE_NORMAL,
  60. NULL);
  61. if (hf != INVALID_HANDLE_VALUE)
  62. {
  63. SetFilePointer(hf, 0, NULL, FILE_END);
  64. WriteFile(hf, buf, lstrlen(buf), &dwWritten, NULL);
  65. CloseHandle(hf);
  66. }
  67. }
  68. #else
  69. VOID PINFO (LPTSTR format, ...)
  70. {
  71. }
  72. #endif