Source code of Windows XP (NT5)
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.

92 lines
2.4 KiB

  1. #ifndef _SSDPSTATUS_
  2. #define _SSDPSTATUS_
  3. #include <windows.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <tchar.h>
  7. #ifdef DBG
  8. #define ERROR_STR_SIZE 1025
  9. #define SSDP_DEBUG_RPC_INIT 0x00000001
  10. #define SSDP_DEBUG_RPC_STOP 0x00000002
  11. #define SSDP_DEBUG_RPC_IF 0x00000004
  12. #define SSDP_DEBUG_SOCKET 0x00000008
  13. #define SSDP_DEBUG_ANNOUNCE 0x00000010
  14. #define SSDP_DEBUG_NETWORK 0x00000020
  15. #define SSDP_DEBUG_PARSER 0x00000040
  16. #define SSDP_DEBUG_SEARCH_RESP 0x00000080
  17. #define SSDP_DEBUG_SYS_SVC 0x00000100
  18. #define SSDP_DEBUG_CACHE 0x00000200
  19. #define SSDP_DEBUG_NOTIFY 0x00000400
  20. // RPC Client
  21. #define SSDP_DEBUG_C_RPC_INIT 0x00000800
  22. #define SSDP_DEBUG_C_NOTIFY 0x00001000
  23. #define SSDP_DEBUG_C_SEARCH 0x00002000
  24. #define SSDP_DEBUG_C_PUBLISH 0x00004000
  25. // 1MB
  26. #define LOG_SIZE 1048576
  27. #define EnterStatusToLog(flag, comment, status) { \
  28. if (LogLevel & (SSDP_DEBUG_ ## flag)) { \
  29. TCHAR szError[ERROR_STR_SIZE]; \
  30. int charWritten; \
  31. EnterCriticalSection(&CSLogFile); \
  32. FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, \
  33. NULL, \
  34. status, \
  35. 0, \
  36. szError, \
  37. ERROR_STR_SIZE, \
  38. NULL); \
  39. charWritten = _ftprintf(fileLog, "%s %s", comment, szError); \
  40. LogSize += charWritten * sizeof(TCHAR); \
  41. if (LogSize > LOG_SIZE) { \
  42. CleanupLogFile(); \
  43. } \
  44. fflush(fileLog); \
  45. LeaveCriticalSection(&CSLogFile); \
  46. } \
  47. }
  48. #define EnterMsgToLog(flag, print) { \
  49. if (LogLevel & (SSDP_DEBUG_ ## flag)) { \
  50. int charWritten; \
  51. EnterCriticalSection(&CSLogFile); \
  52. charWritten = fwprintf print; \
  53. LogSize += charWritten * sizeof(wchar_t); \
  54. if (LogSize > LOG_SIZE) { \
  55. CleanupLogFile(); \
  56. } \
  57. fflush(fileLog); \
  58. LeaveCriticalSection(&CSLogFile); \
  59. } \
  60. }
  61. #else
  62. #define EnterMsgToLog(flag, print)
  63. #define EnterStatusToLog(flag, comment, status)
  64. #endif // DBG
  65. #define ABORT_ON_FAILURE(status) \
  66. if (status != 0) { \
  67. goto cleanup; \
  68. }
  69. extern unsigned long LogLevel;
  70. extern FILE *fileLog;
  71. extern CRITICAL_SECTION CSLogFile;
  72. extern long LogSize;
  73. void CleanupLogFile();
  74. int OpenLogFileHandle(char * fileName);
  75. void CloseLogFileHandle(FILE *fileLog);
  76. #endif // _SSDPSTATUS_