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.

199 lines
3.9 KiB

  1. /*
  2. * resstr.c - Return code to string translation routines.
  3. */
  4. /* Headers
  5. **********/
  6. #include "project.h"
  7. #pragma hdrstop
  8. #include <intshcut.h>
  9. #ifdef DEBUG
  10. /* Macros
  11. *********/
  12. /*
  13. * macro for simplifying result to string translation, assumes result string
  14. * pointer pcsz
  15. */
  16. #define STRING_CASE(val) case val: pcsz = #val; break
  17. /****************************** Public Functions *****************************/
  18. PUBLIC_CODE PCSTR GetINTString(int n)
  19. {
  20. static char s_rgchINT[] = "-2147483646";
  21. wsprintf(s_rgchINT, "%d", n);
  22. ASSERT(IS_VALID_STRING_PTR(s_rgchINT, CSTR));
  23. return(s_rgchINT);
  24. }
  25. PUBLIC_CODE PCSTR GetULONGString(ULONG ul)
  26. {
  27. static char s_rgchULONG[] = "4294967295";
  28. wsprintf(s_rgchULONG, "%lx", ul);
  29. ASSERT(IS_VALID_STRING_PTR(s_rgchULONG, CSTR));
  30. return(s_rgchULONG);
  31. }
  32. PUBLIC_CODE PCSTR GetBOOLString(BOOL bResult)
  33. {
  34. PCSTR pcsz;
  35. pcsz = bResult ? "TRUE" : "FALSE";
  36. ASSERT(IS_VALID_STRING_PTR(pcsz, CSTR));
  37. return(pcsz);
  38. }
  39. PUBLIC_CODE PCSTR GetClipboardFormatNameString(UINT ucf)
  40. {
  41. PCSTR pcsz;
  42. static char s_szCFName[MAX_PATH_LEN];
  43. switch (ucf)
  44. {
  45. STRING_CASE(CF_TEXT);
  46. STRING_CASE(CF_BITMAP);
  47. STRING_CASE(CF_METAFILEPICT);
  48. STRING_CASE(CF_SYLK);
  49. STRING_CASE(CF_DIF);
  50. STRING_CASE(CF_TIFF);
  51. STRING_CASE(CF_OEMTEXT);
  52. STRING_CASE(CF_DIB);
  53. STRING_CASE(CF_PALETTE);
  54. STRING_CASE(CF_PENDATA);
  55. STRING_CASE(CF_RIFF);
  56. STRING_CASE(CF_WAVE);
  57. STRING_CASE(CF_UNICODETEXT);
  58. STRING_CASE(CF_ENHMETAFILE);
  59. STRING_CASE(CF_HDROP);
  60. STRING_CASE(CF_LOCALE);
  61. STRING_CASE(CF_MAX);
  62. STRING_CASE(CF_OWNERDISPLAY);
  63. STRING_CASE(CF_DSPTEXT);
  64. STRING_CASE(CF_DSPBITMAP);
  65. STRING_CASE(CF_DSPMETAFILEPICT);
  66. STRING_CASE(CF_DSPENHMETAFILE);
  67. default:
  68. if (! GetClipboardFormatName(ucf, s_szCFName, sizeof(s_szCFName)))
  69. lstrcpy(s_szCFName, "UNKNOWN CLIPBOARD FORMAT");
  70. pcsz = s_szCFName;
  71. break;
  72. }
  73. ASSERT(IS_VALID_STRING_PTR(pcsz, CSTR));
  74. return(pcsz);
  75. }
  76. PUBLIC_CODE PCSTR GetCOMPARISONRESULTString(COMPARISONRESULT cr)
  77. {
  78. PCSTR pcsz;
  79. switch (cr)
  80. {
  81. STRING_CASE(CR_FIRST_SMALLER);
  82. STRING_CASE(CR_FIRST_LARGER);
  83. STRING_CASE(CR_EQUAL);
  84. default:
  85. ERROR_OUT(("GetCOMPARISONRESULTString() called on unknown COMPARISONRESULT %d.",
  86. cr));
  87. pcsz = "UNKNOWN COMPARISONRESULT";
  88. break;
  89. }
  90. ASSERT(IS_VALID_STRING_PTR(pcsz, CSTR));
  91. return(pcsz);
  92. }
  93. #ifdef INC_OLE2
  94. PUBLIC_CODE PCSTR GetHRESULTString(HRESULT hr)
  95. {
  96. PCSTR pcsz;
  97. static char s_rgchHRESULT[] = "0x12345678";
  98. switch (hr)
  99. {
  100. STRING_CASE(S_OK);
  101. STRING_CASE(S_FALSE);
  102. STRING_CASE(DRAGDROP_S_CANCEL);
  103. STRING_CASE(DRAGDROP_S_DROP);
  104. STRING_CASE(DRAGDROP_S_USEDEFAULTCURSORS);
  105. STRING_CASE(E_UNEXPECTED);
  106. STRING_CASE(E_NOTIMPL);
  107. STRING_CASE(E_OUTOFMEMORY);
  108. STRING_CASE(E_INVALIDARG);
  109. STRING_CASE(E_NOINTERFACE);
  110. STRING_CASE(E_POINTER);
  111. STRING_CASE(E_HANDLE);
  112. STRING_CASE(E_ABORT);
  113. STRING_CASE(E_FAIL);
  114. STRING_CASE(E_ACCESSDENIED);
  115. STRING_CASE(CLASS_E_NOAGGREGATION);
  116. STRING_CASE(CO_E_NOTINITIALIZED);
  117. STRING_CASE(CO_E_ALREADYINITIALIZED);
  118. STRING_CASE(CO_E_INIT_ONLY_SINGLE_THREADED);
  119. STRING_CASE(DV_E_DVASPECT);
  120. STRING_CASE(DV_E_LINDEX);
  121. STRING_CASE(DV_E_TYMED);
  122. STRING_CASE(DV_E_FORMATETC);
  123. #ifdef __INTSHCUT_H__
  124. STRING_CASE(E_FLAGS);
  125. STRING_CASE(URL_E_INVALID_SYNTAX);
  126. STRING_CASE(URL_E_UNREGISTERED_PROTOCOL);
  127. STRING_CASE(IS_E_EXEC_FAILED);
  128. STRING_CASE(E_FILE_NOT_FOUND);
  129. STRING_CASE(E_PATH_NOT_FOUND);
  130. #endif
  131. default:
  132. wsprintf(s_rgchHRESULT, "%#lx", hr);
  133. pcsz = s_rgchHRESULT;
  134. break;
  135. }
  136. ASSERT(IS_VALID_STRING_PTR(pcsz, CSTR));
  137. return(pcsz);
  138. }
  139. #endif /* INC_OLE2 */
  140. #endif /* DEBUG */