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.

150 lines
2.5 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. rtrmgr.c
  5. Abstract:
  6. The major router management functions
  7. Author:
  8. Stefan Solomon 03/22/1995
  9. Revision History:
  10. --*/
  11. #include "precomp.h"
  12. #pragma hdrstop
  13. //*** TRACE ID FOR ROUTER MANAGER ***
  14. DWORD RMTraceID = INVALID_TRACEID;
  15. HANDLE RMEventLogHdl = NULL;
  16. DWORD RMEventLogMask = 0;
  17. #if DBG
  18. DWORD DbgLevel = DEFAULT_DEBUG;
  19. DWORD DebugLog = 1;
  20. HANDLE DbgLogFileHandle;
  21. VOID
  22. SsDbgInitialize(VOID)
  23. {
  24. if (DebugLog == 1) {
  25. CONSOLE_SCREEN_BUFFER_INFO csbi;
  26. COORD coord;
  27. (VOID)AllocConsole( );
  28. (VOID)GetConsoleScreenBufferInfo(
  29. GetStdHandle(STD_OUTPUT_HANDLE),
  30. &csbi
  31. );
  32. coord.X = (SHORT)(csbi.srWindow.Right - csbi.srWindow.Left + 1);
  33. coord.Y = (SHORT)((csbi.srWindow.Bottom - csbi.srWindow.Top + 1) * 20);
  34. (VOID)SetConsoleScreenBufferSize(
  35. GetStdHandle(STD_OUTPUT_HANDLE),
  36. coord
  37. );
  38. }
  39. if(DebugLog > 1) {
  40. DbgLogFileHandle = CreateFile("\\ipxrtdbg.log",
  41. GENERIC_READ | GENERIC_WRITE,
  42. FILE_SHARE_READ,
  43. NULL,
  44. CREATE_ALWAYS,
  45. 0,
  46. NULL);
  47. }
  48. }
  49. VOID
  50. SsAssert(
  51. IN PVOID FailedAssertion,
  52. IN PVOID FileName,
  53. IN ULONG LineNumber
  54. )
  55. {
  56. Trace(ROUTER_ALERT, "\nAssertion failed: %s\n at line %ld of %s\n",
  57. FailedAssertion, LineNumber, FileName);
  58. DbgUserBreakPoint( );
  59. } // SsAssert
  60. #endif
  61. #if DBG
  62. VOID
  63. SsPrintf (
  64. char *Format,
  65. ...
  66. )
  67. {
  68. va_list arglist;
  69. char OutputBuffer[1024];
  70. ULONG length;
  71. va_start( arglist, Format );
  72. vsprintf( OutputBuffer, Format, arglist );
  73. va_end( arglist );
  74. length = strlen( OutputBuffer );
  75. WriteFile( GetStdHandle(STD_OUTPUT_HANDLE), (LPVOID )OutputBuffer, length, &length, NULL );
  76. if(DbgLogFileHandle != INVALID_HANDLE_VALUE) {
  77. WriteFile(DbgLogFileHandle, (LPVOID )OutputBuffer, length, &length, NULL );
  78. }
  79. } // SsPrintf
  80. #endif
  81. VOID
  82. StartTracing(VOID)
  83. {
  84. RMTraceID = TraceRegisterA("IPXRouterManager");
  85. RMEventLogHdl = RouterLogRegisterA ("IPXRouterManager");
  86. }
  87. VOID
  88. Trace(ULONG ComponentID,
  89. char *Format,
  90. ...)
  91. {
  92. if (RMTraceID!=INVALID_TRACEID) {
  93. va_list arglist;
  94. va_start(arglist, Format);
  95. TraceVprintfEx(RMTraceID,
  96. ComponentID | TRACE_USE_MASK,
  97. Format,
  98. arglist);
  99. va_end(arglist);
  100. }
  101. }
  102. VOID
  103. StopTracing(VOID)
  104. {
  105. if (RMTraceID!=INVALID_TRACEID)
  106. TraceDeregister(RMTraceID);
  107. if (RMEventLogHdl!=NULL)
  108. RouterLogDeregisterA (RMEventLogHdl);
  109. }