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.

143 lines
3.7 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. if (szMessage)
  54. {
  55. _snprintf(szDebug, MAX_PATH, "%d.%d> ASSERTION FAILED: %s, %s:%d\n",
  56. GetCurrentProcessId(), GetCurrentThreadId(),
  57. szMessage, szFile, iLine);
  58. }
  59. else
  60. {
  61. _snprintf(szDebug, MAX_PATH, "%d.%d> ASSERTION FAILED %s:%d\n",
  62. GetCurrentProcessId(), GetCurrentThreadId(),
  63. szFile, iLine);
  64. }
  65. OutputDebugStringA(szDebug);
  66. DebugBreak();
  67. }
  68. //+------------------------------------------------------------
  69. // Function: SetWin4InfoLevel(unsigned long ulNewLevel)
  70. //
  71. // Synopsis: Sets the global info level for debugging output
  72. // Returns: Old info level
  73. //
  74. //-------------------------------------------------------------
  75. unsigned long
  76. SetWin4InfoLevel(
  77. unsigned long ulNewLevel)
  78. {
  79. return(ulNewLevel);
  80. }
  81. //+------------------------------------------------------------
  82. // Function: _SetWin4InfoMask(unsigned long ulNewMask)
  83. //
  84. // Synopsis: Sets the global info mask for debugging output
  85. // Returns: Old info mask
  86. //
  87. //-------------------------------------------------------------
  88. unsigned long
  89. SetWin4InfoMask(
  90. unsigned long ulNewMask)
  91. {
  92. return(ulNewMask);
  93. }
  94. //+------------------------------------------------------------
  95. // Function: _SetWin4AssertLevel(unsigned long ulNewLevel)
  96. //
  97. // Synopsis: Sets the global assert level for debugging output
  98. // Returns: Old assert level
  99. //
  100. //-------------------------------------------------------------
  101. typedef unsigned long (APINOT * SetWin4AssertLevelFn)( unsigned long ulNewLevel );
  102. unsigned long
  103. SetWin4AssertLevel(
  104. unsigned long ulNewLevel)
  105. {
  106. SetWin4AssertLevelFn OleSetWin4AssertLevel;
  107. HMODULE Module;
  108. Module = GetModuleHandle(L"ole32.dll");
  109. if (Module != NULL)
  110. {
  111. OleSetWin4AssertLevel = (SetWin4AssertLevelFn) GetProcAddress(Module, "SetWin4AssertLevel");
  112. if (OleSetWin4AssertLevel != NULL)
  113. {
  114. OleSetWin4AssertLevel(ulNewLevel);
  115. }
  116. }
  117. return(ulNewLevel);
  118. }