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.

152 lines
2.5 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. util.c
  5. Abstract:
  6. Battery Class Installer utility routines
  7. Author:
  8. Scott Brenden
  9. Environment:
  10. Notes:
  11. Revision History:
  12. --*/
  13. #include "proj.h"
  14. #if defined(DEBUG)
  15. DWORD BattDebugPrintLevel = TF_ERROR | TF_WARNING;
  16. void
  17. CPUBLIC
  18. CommonDebugMsgW(
  19. DWORD Flag,
  20. LPCSTR Message,
  21. ...
  22. )
  23. /*++
  24. Routine Description:
  25. This is the wide char version of CommonDebugMsgA
  26. Arguments:
  27. Flag - Debug print level for message
  28. Message - Format string for message
  29. ... - Arguments for the format string
  30. Return Value:
  31. --*/
  32. {
  33. WCHAR tmpBuffer[DEBUG_PRINT_BUFFER_LEN]; // Largest path plus extra
  34. va_list variableArgs;
  35. if (Flag & BattDebugPrintLevel)
  36. {
  37. int wideCharCount;
  38. int tmpInt;
  39. WCHAR wideBuffer[MAX_BUF];
  40. lstrcpyW (tmpBuffer, L"BATTERY CLASS INSTALLER: ");
  41. wideCharCount = lstrlenW (tmpBuffer);
  42. va_start(variableArgs, Message);
  43. // (We convert the string, rather than simply input an
  44. // LPCWSTR parameter, so the caller doesn't have to wrap
  45. // all the string constants with the TEXT() macro.)
  46. tmpInt = MultiByteToWideChar(CP_ACP, 0, Message, lstrlenA (Message), wideBuffer, MAX_BUF);
  47. if (!tmpInt) {
  48. lstrcatW (tmpBuffer, L"Debug string too long to print\n");
  49. } else {
  50. wvsprintfW (&tmpBuffer[wideCharCount-sizeof(WCHAR)], wideBuffer, variableArgs);
  51. }
  52. va_end(variableArgs);
  53. OutputDebugStringW(tmpBuffer);
  54. }
  55. }
  56. void
  57. CPUBLIC
  58. CommonDebugMsgA(
  59. DWORD Flag,
  60. LPCSTR Message,
  61. ...
  62. )
  63. /*++
  64. Routine Description:
  65. Debug spew
  66. Arguments:
  67. Flag - Debug print level for message
  68. Message - Format string for message
  69. ... - Arguments for the format string
  70. Return Value:
  71. --*/
  72. {
  73. UCHAR tmpBuffer[DEBUG_PRINT_BUFFER_LEN]; // Largest path plus extra
  74. va_list variableArgs;
  75. if (Flag & BattDebugPrintLevel)
  76. {
  77. int charCount;
  78. lstrcpyA (tmpBuffer, "BATTERY CLASS INSTALLER: ");
  79. charCount = lstrlenA (tmpBuffer);
  80. va_start(variableArgs, Message);
  81. wvsprintfA (&tmpBuffer[charCount-1], Message, variableArgs);
  82. va_end(variableArgs);
  83. OutputDebugStringA(tmpBuffer);
  84. }
  85. }
  86. #endif // #if defined(DEBUG)