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.

145 lines
3.9 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: compat.c
  7. //
  8. // Contents: Compatibility routines for old callers
  9. //
  10. // Classes:
  11. //
  12. // Functions:
  13. //
  14. // History: 3-14-95 RichardW Created
  15. //
  16. //----------------------------------------------------------------------------
  17. #include "debuglib.h"
  18. #include <debnot.h>
  19. DWORD __CompatInfoLevel = 3;
  20. DebugModule __CompatGlobal = {NULL, NULL, 0, 0, &__CompatHeader};
  21. DebugHeader __CompatHeader = {DEBUG_TAG, NULL, INVALID_HANDLE_VALUE,
  22. INVALID_HANDLE_VALUE, 0, &__CompatGlobal};
  23. DebugModule __CompatModule = {NULL, &__CompatInfoLevel, 0, 3,
  24. &__CompatHeader, 0, 0, "Compat",
  25. {"Error", "Warning", "Trace", "",
  26. "IError", "IWarning", "ITrace", "",
  27. "", "", "", "", "", "", "", "",
  28. "", "", "", "", "", "", "", "",
  29. "", "", "", "", "", "", "", "" }
  30. };
  31. DebugModule * __pCompatModule = &__CompatModule;
  32. void
  33. vdprintf(
  34. unsigned long ulCompMask,
  35. char const *pszComp,
  36. char const *ppszfmt,
  37. va_list ArgList)
  38. {
  39. __CompatModule.pModuleName = (char *) pszComp;
  40. if (DbgpHeader)
  41. {
  42. __CompatModule.pHeader = DbgpHeader;
  43. }
  44. _DebugOut(__pCompatModule, ulCompMask, (char *) ppszfmt, ArgList);
  45. }
  46. void
  47. Win4AssertEx(
  48. char const * szFile,
  49. int iLine,
  50. char const * szMessage)
  51. {
  52. CHAR szDebug[MAX_PATH];
  53. szDebug[RTL_NUMBER_OF(szDebug) - 1] = '\0';
  54. if (szMessage)
  55. {
  56. _snprintf(szDebug, RTL_NUMBER_OF(szDebug) - 1, "%d.%d> ASSERTION FAILED: %s, %s:%d\n",
  57. GetCurrentProcessId(), GetCurrentThreadId(),
  58. szMessage, szFile, iLine);
  59. }
  60. else
  61. {
  62. _snprintf(szDebug, RTL_NUMBER_OF(szDebug) - 1, "%d.%d> ASSERTION FAILED %s:%d\n",
  63. GetCurrentProcessId(), GetCurrentThreadId(),
  64. szFile, iLine);
  65. }
  66. OutputDebugStringA(szDebug);
  67. DebugBreak();
  68. }
  69. //+------------------------------------------------------------
  70. // Function: SetWin4InfoLevel(unsigned long ulNewLevel)
  71. //
  72. // Synopsis: Sets the global info level for debugging output
  73. // Returns: Old info level
  74. //
  75. //-------------------------------------------------------------
  76. unsigned long
  77. SetWin4InfoLevel(
  78. unsigned long ulNewLevel)
  79. {
  80. return(ulNewLevel);
  81. }
  82. //+------------------------------------------------------------
  83. // Function: _SetWin4InfoMask(unsigned long ulNewMask)
  84. //
  85. // Synopsis: Sets the global info mask for debugging output
  86. // Returns: Old info mask
  87. //
  88. //-------------------------------------------------------------
  89. unsigned long
  90. SetWin4InfoMask(
  91. unsigned long ulNewMask)
  92. {
  93. return(ulNewMask);
  94. }
  95. //+------------------------------------------------------------
  96. // Function: _SetWin4AssertLevel(unsigned long ulNewLevel)
  97. //
  98. // Synopsis: Sets the global assert level for debugging output
  99. // Returns: Old assert level
  100. //
  101. //-------------------------------------------------------------
  102. typedef unsigned long (APINOT * SetWin4AssertLevelFn)( unsigned long ulNewLevel );
  103. unsigned long
  104. SetWin4AssertLevel(
  105. unsigned long ulNewLevel)
  106. {
  107. SetWin4AssertLevelFn OleSetWin4AssertLevel;
  108. HMODULE Module;
  109. Module = GetModuleHandle(L"ole32.dll");
  110. if (Module != NULL)
  111. {
  112. OleSetWin4AssertLevel = (SetWin4AssertLevelFn) GetProcAddress(Module, "SetWin4AssertLevel");
  113. if (OleSetWin4AssertLevel != NULL)
  114. {
  115. OleSetWin4AssertLevel(ulNewLevel);
  116. }
  117. }
  118. return(ulNewLevel);
  119. }