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.

117 lines
2.6 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. debug.c
  5. Abstract: This module contains all the debug functions.
  6. Environment:
  7. User mode
  8. Author:
  9. Michael Tsang (MikeTs) 13-Mar-2000
  10. Revision History:
  11. --*/
  12. #include "pch.h"
  13. #ifdef DEBUG
  14. NAMETABLE CPLMsgNames[] =
  15. {
  16. CPL_INIT, "Init",
  17. CPL_GETCOUNT, "GetCount",
  18. CPL_INQUIRE, "Inquire",
  19. CPL_SELECT, "Select",
  20. CPL_DBLCLK, "DoubleClick",
  21. CPL_STOP, "Stop",
  22. CPL_EXIT, "Exit",
  23. CPL_NEWINQUIRE, "NewInquire",
  24. CPL_STARTWPARMSA, "StartWParamsA",
  25. CPL_STARTWPARMSW, "StartWParamsW",
  26. CPL_SETUP, "Setup",
  27. 0x00, NULL
  28. };
  29. #endif //ifdef DEBUG
  30. /*++
  31. @doc INTERNAL
  32. @func VOID | ErrorMsg | Put out an error message box.
  33. @parm IN ULONG | ErrCode | The given error code.
  34. @parm ... | Substituting arguments for the error message.
  35. @rvalue Returns the number of chars in the message.
  36. --*/
  37. int INTERNAL
  38. ErrorMsg(
  39. IN ULONG ErrCode,
  40. ...
  41. )
  42. {
  43. static TCHAR tszFormat[1024];
  44. static TCHAR tszErrMsg[1024];
  45. int n;
  46. va_list arglist;
  47. LoadString(ghInstance, ErrCode, tszFormat, sizeof(tszFormat)/sizeof(TCHAR));
  48. va_start(arglist, ErrCode);
  49. n = wvsprintf(tszErrMsg, tszFormat, arglist);
  50. va_end(arglist);
  51. MessageBox(NULL, tszErrMsg, gtszTitle, MB_OK | MB_ICONERROR);
  52. return n;
  53. } //ErrorMsg
  54. /*++
  55. @doc INTERNAL
  56. @func ULONG | MapError | Map error from one component to another.
  57. @parm IN ULONG | dwErrCode | The given error code.
  58. @parm IN PERRMAP | ErrorMap | Points to the error map.
  59. @parm IN BOOL | fReverse | If TRUE, do a reverse lookup.
  60. @rvalue Returns the mapped error number.
  61. --*/
  62. ULONG INTERNAL
  63. MapError(
  64. IN ULONG dwErrCode,
  65. IN PERRMAP ErrorMap,
  66. IN BOOL fReverse
  67. )
  68. {
  69. ULONG dwMapErr = 0;
  70. while ((ErrorMap->dwFromCode != 0) || (ErrorMap->dwToCode != 0))
  71. {
  72. if (!fReverse)
  73. {
  74. if (dwErrCode == ErrorMap->dwFromCode)
  75. {
  76. dwMapErr = ErrorMap->dwToCode;
  77. break;
  78. }
  79. }
  80. else
  81. {
  82. if (dwErrCode == ErrorMap->dwToCode)
  83. {
  84. dwMapErr = ErrorMap->dwFromCode;
  85. break;
  86. }
  87. }
  88. ErrorMap++;
  89. }
  90. return dwMapErr;
  91. } //MapError