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.

286 lines
7.0 KiB

  1. /*
  2. * resstr.c - Return code to string translation routines.
  3. *
  4. * Taken from URL code
  5. *
  6. * Created: ChrisPi 9-11-95
  7. *
  8. */
  9. /* Headers
  10. **********/
  11. #include "precomp.h"
  12. #include "uls2.h"
  13. /* Macros
  14. *********/
  15. /*
  16. * macro for simplifying result to string translation, assumes result string
  17. * pointer pcsz
  18. */
  19. #define STRING_CASE(val) case val: pcsz = #val; break
  20. /****************************** Public Functions *****************************/
  21. #ifdef DEBUG
  22. PCSTR GetINTString(int n)
  23. {
  24. static char s_rgchINT[] = "-2147483646";
  25. wsprintfA(s_rgchINT, "%d", n);
  26. ASSERT(IS_VALID_STRING_PTR_A(s_rgchINT, CSTR));
  27. return(s_rgchINT);
  28. }
  29. PCSTR GetINT_PTRString(INT_PTR n)
  30. {
  31. static char s_rgchINT[] = "-2147483646xxxxxxxxxx";
  32. wsprintfA(s_rgchINT, "%Id", n);
  33. ASSERT(IS_VALID_STRING_PTR_A(s_rgchINT, CSTR));
  34. return(s_rgchINT);
  35. }
  36. PCSTR GetULONGString(ULONG ul)
  37. {
  38. static char s_rgchULONG[] = "4294967295";
  39. wsprintfA(s_rgchULONG, "%lx", ul);
  40. ASSERT(IS_VALID_STRING_PTR_A(s_rgchULONG, CSTR));
  41. return(s_rgchULONG);
  42. }
  43. PCSTR GetBOOLString(BOOL bResult)
  44. {
  45. PCSTR pcsz;
  46. pcsz = bResult ? "TRUE" : "FALSE";
  47. ASSERT(IS_VALID_STRING_PTR_A(pcsz, CSTR));
  48. return(pcsz);
  49. }
  50. PCSTR GetPVOIDString(PVOID ptr)
  51. {
  52. static char s_rgchPVOID[] = "0xffff0000ffff0000";
  53. wsprintfA(s_rgchPVOID, "0x%p", ptr);
  54. ASSERT(IS_VALID_STRING_PTR_A(s_rgchPVOID, CSTR));
  55. return(s_rgchPVOID);
  56. }
  57. PCSTR GetClipboardFormatNameString(UINT ucf)
  58. {
  59. PCSTR pcsz;
  60. static char s_szCFName[MAX_PATH];
  61. switch (ucf)
  62. {
  63. STRING_CASE(CF_TEXT);
  64. STRING_CASE(CF_BITMAP);
  65. STRING_CASE(CF_METAFILEPICT);
  66. STRING_CASE(CF_SYLK);
  67. STRING_CASE(CF_DIF);
  68. STRING_CASE(CF_TIFF);
  69. STRING_CASE(CF_OEMTEXT);
  70. STRING_CASE(CF_DIB);
  71. STRING_CASE(CF_PALETTE);
  72. STRING_CASE(CF_PENDATA);
  73. STRING_CASE(CF_RIFF);
  74. STRING_CASE(CF_WAVE);
  75. STRING_CASE(CF_UNICODETEXT);
  76. STRING_CASE(CF_ENHMETAFILE);
  77. STRING_CASE(CF_HDROP);
  78. STRING_CASE(CF_LOCALE);
  79. STRING_CASE(CF_MAX);
  80. STRING_CASE(CF_OWNERDISPLAY);
  81. STRING_CASE(CF_DSPTEXT);
  82. STRING_CASE(CF_DSPBITMAP);
  83. STRING_CASE(CF_DSPMETAFILEPICT);
  84. STRING_CASE(CF_DSPENHMETAFILE);
  85. default:
  86. if (! GetClipboardFormatNameA(ucf, s_szCFName, sizeof(s_szCFName)))
  87. lstrcpyA(s_szCFName, "UNKNOWN CLIPBOARD FORMAT");
  88. pcsz = s_szCFName;
  89. break;
  90. }
  91. ASSERT(IS_VALID_STRING_PTR_A(pcsz, CSTR));
  92. return(pcsz);
  93. }
  94. PCSTR GetCOMPARISONRESULTString(COMPARISONRESULT cr)
  95. {
  96. PCSTR pcsz;
  97. switch (cr)
  98. {
  99. STRING_CASE(CR_FIRST_SMALLER);
  100. STRING_CASE(CR_FIRST_LARGER);
  101. STRING_CASE(CR_EQUAL);
  102. default:
  103. ERROR_OUT(("GetCOMPARISONRESULTString() called on unknown COMPARISONRESULT %d.",
  104. cr));
  105. pcsz = "UNKNOWN COMPARISONRESULT";
  106. break;
  107. }
  108. ASSERT(IS_VALID_STRING_PTR_A(pcsz, CSTR));
  109. return(pcsz);
  110. }
  111. PCSTR GetHRESULTString(HRESULT hr)
  112. {
  113. PCSTR pcsz;
  114. static char s_rgchHRESULT[] = "0x12345678";
  115. switch (hr)
  116. {
  117. STRING_CASE(S_OK);
  118. STRING_CASE(S_FALSE);
  119. STRING_CASE(DRAGDROP_S_CANCEL);
  120. STRING_CASE(DRAGDROP_S_DROP);
  121. STRING_CASE(DRAGDROP_S_USEDEFAULTCURSORS);
  122. STRING_CASE(E_UNEXPECTED);
  123. STRING_CASE(E_NOTIMPL);
  124. STRING_CASE(E_OUTOFMEMORY);
  125. STRING_CASE(E_INVALIDARG);
  126. STRING_CASE(E_NOINTERFACE);
  127. STRING_CASE(E_POINTER);
  128. STRING_CASE(E_HANDLE);
  129. STRING_CASE(E_ABORT);
  130. STRING_CASE(E_FAIL);
  131. STRING_CASE(E_ACCESSDENIED);
  132. STRING_CASE(CLASS_E_NOAGGREGATION);
  133. STRING_CASE(CO_E_NOTINITIALIZED);
  134. STRING_CASE(CO_E_ALREADYINITIALIZED);
  135. STRING_CASE(CO_E_INIT_ONLY_SINGLE_THREADED);
  136. STRING_CASE(DV_E_DVASPECT);
  137. STRING_CASE(DV_E_LINDEX);
  138. STRING_CASE(DV_E_TYMED);
  139. STRING_CASE(DV_E_FORMATETC);
  140. #ifdef __INTSHCUT_H__
  141. STRING_CASE(E_FLAGS);
  142. STRING_CASE(URL_E_INVALID_SYNTAX);
  143. STRING_CASE(URL_E_UNREGISTERED_PROTOCOL);
  144. STRING_CASE(IS_E_EXEC_FAILED);
  145. STRING_CASE(E_FILE_NOT_FOUND);
  146. STRING_CASE(E_PATH_NOT_FOUND);
  147. #endif
  148. // ULS error codes
  149. //
  150. STRING_CASE(ILS_E_SERVER_SERVICE);
  151. STRING_CASE(ILS_E_SERVER_NAME);
  152. STRING_CASE(ILS_E_TIMEOUT);
  153. STRING_CASE(ILS_E_BIND);
  154. STRING_CASE(ILS_E_THREAD);
  155. STRING_CASE(ILS_E_SERVER_EXEC);
  156. STRING_CASE(ILS_E_WINSOCK);
  157. STRING_CASE(ILS_E_NO_MORE);
  158. STRING_CASE(ILS_E_NOT_INITIALIZED);
  159. STRING_CASE(ILS_E_NOTIFY_ID);
  160. STRING_CASE(ILS_E_NO_SUCH_OBJECT);
  161. STRING_CASE(ILS_E_NEED_RELOGON);
  162. STRING_CASE(ILS_E_NAME_CONFLICTS);
  163. // LDAP specific error codes
  164. //
  165. STRING_CASE(ILS_E_LDAP_OPERATIONS_ERROR);
  166. STRING_CASE(ILS_E_LDAP_PROTOCOL_ERROR);
  167. STRING_CASE(ILS_E_LDAP_TIMELIMIT_EXCEEDED);
  168. STRING_CASE(ILS_E_LDAP_SIZELIMIT_EXCEEDED);
  169. STRING_CASE(ILS_E_LDAP_COMPARE_FALSE);
  170. STRING_CASE(ILS_E_LDAP_COMPARE_TRUE);
  171. STRING_CASE(ILS_E_LDAP_AUTH_METHOD_NOT_SUPPORTED);
  172. STRING_CASE(ILS_E_LDAP_STRONG_AUTH_REQUIRED);
  173. STRING_CASE(ILS_E_LDAP_REFERRAL_V2);
  174. STRING_CASE(ILS_E_LDAP_PARTIAL_RESULTS);
  175. STRING_CASE(ILS_E_LDAP_REFERRAL);
  176. STRING_CASE(ILS_E_LDAP_ADMIN_LIMIT_EXCEEDED);
  177. STRING_CASE(ILS_E_LDAP_UNAVAILABLE_CRIT_EXTENSION);
  178. STRING_CASE(ILS_E_LDAP_NO_SUCH_ATTRIBUTE);
  179. STRING_CASE(ILS_E_LDAP_UNDEFINED_TYPE);
  180. STRING_CASE(ILS_E_LDAP_INAPPROPRIATE_MATCHING);
  181. STRING_CASE(ILS_E_LDAP_CONSTRAINT_VIOLATION);
  182. STRING_CASE(ILS_E_LDAP_ATTRIBUTE_OR_VALUE_EXISTS);
  183. STRING_CASE(ILS_E_LDAP_INVALID_SYNTAX);
  184. STRING_CASE(ILS_E_LDAP_ALIAS_PROBLEM);
  185. STRING_CASE(ILS_E_LDAP_INVALID_DN_SYNTAX);
  186. STRING_CASE(ILS_E_LDAP_IS_LEAF);
  187. STRING_CASE(ILS_E_LDAP_ALIAS_DEREF_PROBLEM);
  188. STRING_CASE(ILS_E_LDAP_INAPPROPRIATE_AUTH);
  189. STRING_CASE(ILS_E_LDAP_INVALID_CREDENTIALS);
  190. STRING_CASE(ILS_E_LDAP_INSUFFICIENT_RIGHTS);
  191. STRING_CASE(ILS_E_LDAP_BUSY);
  192. STRING_CASE(ILS_E_LDAP_UNAVAILABLE);
  193. STRING_CASE(ILS_E_LDAP_UNWILLING_TO_PERFORM);
  194. STRING_CASE(ILS_E_LDAP_LOOP_DETECT);
  195. STRING_CASE(ILS_E_LDAP_NAMING_VIOLATION);
  196. STRING_CASE(ILS_E_LDAP_OBJECT_CLASS_VIOLATION);
  197. STRING_CASE(ILS_E_LDAP_NOT_ALLOWED_ON_NONLEAF);
  198. STRING_CASE(ILS_E_LDAP_NOT_ALLOWED_ON_RDN);
  199. STRING_CASE(ILS_E_LDAP_NO_OBJECT_CLASS_MODS);
  200. STRING_CASE(ILS_E_LDAP_RESULTS_TOO_LARGE);
  201. STRING_CASE(ILS_E_LDAP_AFFECTS_MULTIPLE_DSAS);
  202. STRING_CASE(ILS_E_LDAP_OTHER);
  203. STRING_CASE(ILS_E_LDAP_SERVER_DOWN);
  204. STRING_CASE(ILS_E_LDAP_LOCAL_ERROR);
  205. STRING_CASE(ILS_E_LDAP_ENCODING_ERROR);
  206. STRING_CASE(ILS_E_LDAP_DECODING_ERROR);
  207. STRING_CASE(ILS_E_LDAP_TIMEOUT);
  208. STRING_CASE(ILS_E_LDAP_AUTH_UNKNOWN);
  209. STRING_CASE(ILS_E_LDAP_FILTER_ERROR);
  210. STRING_CASE(ILS_E_LDAP_USER_CANCELLED);
  211. STRING_CASE(ILS_E_LDAP_NO_MEMORY);
  212. default:
  213. wsprintfA(s_rgchHRESULT, "%#lx", hr);
  214. pcsz = s_rgchHRESULT;
  215. break;
  216. }
  217. ASSERT(IS_VALID_STRING_PTR_A(pcsz, CSTR));
  218. return(pcsz);
  219. }
  220. #endif /* DEBUG */