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.

383 lines
7.2 KiB

  1. /*
  2. * resstr.c - Return code to string translation routines.
  3. */
  4. /* Headers
  5. **********/
  6. #include "project.h"
  7. #pragma hdrstop
  8. #ifdef DEBUG
  9. #include "debugstr.h"
  10. #include <shlwapi.h>
  11. #endif
  12. /* Macros
  13. *********/
  14. /*
  15. * macro for simplifying result to string translation, assumes result string
  16. * pointer pcsz
  17. */
  18. #define STRING_CASE(val) case val: pcsz = TEXT(#val); break
  19. /****************************** Public Functions *****************************/
  20. #ifdef DEBUG
  21. /*
  22. ** GetINTString()
  23. **
  24. **
  25. **
  26. ** Arguments:
  27. **
  28. ** Returns:
  29. **
  30. ** Side Effects: none
  31. */
  32. PUBLIC_CODE LPCTSTR GetINTString(int n)
  33. {
  34. static TCHAR SrgchINT[] = TEXT("-2147483646");
  35. wnsprintf(SrgchINT, ARRAYSIZE(SrgchINT), TEXT("%d"), n);
  36. ASSERT(IS_VALID_STRING_PTR(SrgchINT, CSTR));
  37. return(SrgchINT);
  38. }
  39. /*
  40. ** GetULONGString()
  41. **
  42. **
  43. **
  44. ** Arguments:
  45. **
  46. ** Returns:
  47. **
  48. ** Side Effects: none
  49. */
  50. PUBLIC_CODE LPCTSTR GetULONGString(ULONG ul)
  51. {
  52. static TCHAR SrgchULONG[] = TEXT("4294967295");
  53. wnsprintf(SrgchULONG, ARRAYSIZE(SrgchULONG), TEXT("%lx"), ul);
  54. ASSERT(IS_VALID_STRING_PTR(SrgchULONG, CSTR));
  55. return(SrgchULONG);
  56. }
  57. /*
  58. ** GetBOOLString()
  59. **
  60. **
  61. **
  62. ** Arguments:
  63. **
  64. ** Returns:
  65. **
  66. ** Side Effects: none
  67. */
  68. PUBLIC_CODE LPCTSTR GetBOOLString(BOOL bResult)
  69. {
  70. LPCTSTR pcsz;
  71. if (bResult)
  72. pcsz = TEXT("TRUE");
  73. else
  74. pcsz = TEXT("FALSE");
  75. ASSERT(IS_VALID_STRING_PTR(pcsz, CSTR));
  76. return(pcsz);
  77. }
  78. /*
  79. ** GetCOMPARISONRESULTString()
  80. **
  81. **
  82. **
  83. ** Arguments:
  84. **
  85. ** Returns:
  86. **
  87. ** Side Effects: none
  88. */
  89. PUBLIC_CODE LPCTSTR GetCOMPARISONRESULTString(COMPARISONRESULT cr)
  90. {
  91. LPCTSTR pcsz;
  92. switch (cr)
  93. {
  94. STRING_CASE(CR_FIRST_SMALLER);
  95. STRING_CASE(CR_FIRST_LARGER);
  96. STRING_CASE(CR_EQUAL);
  97. default:
  98. ERROR_OUT((TEXT("GetCOMPARISONRESULTString() called on unknown COMPARISONRESULT %d."),
  99. cr));
  100. pcsz = TEXT("UNKNOWN COMPARISONRESULT");
  101. break;
  102. }
  103. ASSERT(IS_VALID_STRING_PTR(pcsz, CSTR));
  104. return(pcsz);
  105. }
  106. #ifdef INC_OLE2
  107. /*
  108. ** GetHRESULTString()
  109. **
  110. **
  111. **
  112. ** Arguments:
  113. **
  114. ** Returns:
  115. **
  116. ** Side Effects: none
  117. */
  118. PUBLIC_CODE LPCTSTR GetHRESULTString(HRESULT hr)
  119. {
  120. LPCTSTR pcsz;
  121. static TCHAR SrgchHRESULT[] = TEXT("0x12345678");
  122. switch (hr)
  123. {
  124. STRING_CASE(S_OK);
  125. STRING_CASE(S_FALSE);
  126. STRING_CASE(E_UNEXPECTED);
  127. STRING_CASE(E_NOTIMPL);
  128. STRING_CASE(E_OUTOFMEMORY);
  129. STRING_CASE(E_INVALIDARG);
  130. STRING_CASE(E_NOINTERFACE);
  131. STRING_CASE(E_POINTER);
  132. STRING_CASE(E_HANDLE);
  133. STRING_CASE(E_ABORT);
  134. STRING_CASE(E_FAIL);
  135. STRING_CASE(E_ACCESSDENIED);
  136. STRING_CASE(CLASS_E_NOAGGREGATION);
  137. STRING_CASE(CO_E_NOTINITIALIZED);
  138. STRING_CASE(CO_E_ALREADYINITIALIZED);
  139. STRING_CASE(CO_E_INIT_ONLY_SINGLE_THREADED);
  140. #ifdef __RECONCIL_H__
  141. STRING_CASE(REC_S_IDIDTHEUPDATES);
  142. STRING_CASE(REC_S_NOTCOMPLETE);
  143. STRING_CASE(REC_S_NOTCOMPLETEBUTPROPAGATE);
  144. STRING_CASE(REC_E_ABORTED);
  145. STRING_CASE(REC_E_NOCALLBACK);
  146. STRING_CASE(REC_E_NORESIDUES);
  147. STRING_CASE(REC_E_TOODIFFERENT);
  148. STRING_CASE(REC_E_INEEDTODOTHEUPDATES);
  149. #endif /* __RECONCIL_H__ */
  150. default:
  151. wnsprintf(SrgchHRESULT, ARRAYSIZE(SrgchHRESULT), TEXT("%#lx"), hr);
  152. pcsz = SrgchHRESULT;
  153. break;
  154. }
  155. ASSERT(IS_VALID_STRING_PTR(pcsz, CSTR));
  156. return(pcsz);
  157. }
  158. #endif /* INC_OLE2 */
  159. #ifdef __SYNCENG_H__
  160. /*
  161. ** GetTWINRESULTString()
  162. **
  163. ** Returns a pointer to the string name of a TWINRESULT return code.
  164. **
  165. ** Arguments: tr - return code to be translated
  166. **
  167. ** Returns:
  168. **
  169. ** Side Effects: none
  170. */
  171. PUBLIC_CODE LPCTSTR GetTWINRESULTString(TWINRESULT tr)
  172. {
  173. LPCTSTR pcsz;
  174. ASSERT(tr >= 0);
  175. if (tr < ARRAY_ELEMENTS(rgcpcszTwinResult))
  176. pcsz = rgcpcszTwinResult[tr];
  177. else
  178. {
  179. ERROR_OUT((TEXT("GetTWINRESULTString() called on unrecognized TWINRESULT %ld."),
  180. tr));
  181. pcsz = TEXT("UNKNOWN TWINRESULT");
  182. }
  183. ASSERT(IS_VALID_STRING_PTR(pcsz, CSTR));
  184. return(pcsz);
  185. }
  186. /*
  187. ** GetCREATERECLISTPROCMSGString()
  188. **
  189. **
  190. **
  191. ** Arguments:
  192. **
  193. ** Returns:
  194. **
  195. ** Side Effects: none
  196. */
  197. PUBLIC_CODE LPCTSTR GetCREATERECLISTPROCMSGString(UINT uCreateRecListMsg)
  198. {
  199. LPCTSTR pcsz;
  200. ASSERT(uCreateRecListMsg >= 0);
  201. if (uCreateRecListMsg < ARRAY_ELEMENTS(rgcpcszCreateRecListMsg))
  202. pcsz = rgcpcszCreateRecListMsg[uCreateRecListMsg];
  203. else
  204. {
  205. ERROR_OUT((TEXT("GetCREATERECLISTPROCMSGString() called on unrecognized RECSTATUSPROC message %u."),
  206. uCreateRecListMsg));
  207. pcsz = TEXT("UNKNOWN RECSTATUSPROC MESSAGE");
  208. }
  209. ASSERT(IS_VALID_STRING_PTR(pcsz, CSTR));
  210. return(pcsz);
  211. }
  212. /*
  213. ** GetRECSTATUSPROCMSGString()
  214. **
  215. **
  216. **
  217. ** Arguments:
  218. **
  219. ** Returns:
  220. **
  221. ** Side Effects: none
  222. */
  223. PUBLIC_CODE LPCTSTR GetRECSTATUSPROCMSGString(UINT uRecStatusMsg)
  224. {
  225. LPCTSTR pcsz;
  226. ASSERT(uRecStatusMsg >= 0);
  227. if (uRecStatusMsg < ARRAY_ELEMENTS(rgcpcszRecStatusMsg))
  228. pcsz = rgcpcszRecStatusMsg[uRecStatusMsg];
  229. else
  230. {
  231. ERROR_OUT((TEXT("GetRECSTATUSPROCMSGString() called on unrecognized RECSTATUSPROC message %u."),
  232. uRecStatusMsg));
  233. pcsz = TEXT("UNKNOWN RECSTATUSPROC MESSAGE");
  234. }
  235. ASSERT(IS_VALID_STRING_PTR(pcsz, CSTR));
  236. return(pcsz);
  237. }
  238. /*
  239. ** GetRECNODESTATEString()
  240. **
  241. **
  242. **
  243. ** Arguments:
  244. **
  245. ** Returns:
  246. **
  247. ** Side Effects: none
  248. */
  249. PUBLIC_CODE LPCTSTR GetRECNODESTATEString(RECNODESTATE rnstate)
  250. {
  251. LPCTSTR pcsz;
  252. switch (rnstate)
  253. {
  254. STRING_CASE(RNS_NEVER_RECONCILED);
  255. STRING_CASE(RNS_UNAVAILABLE);
  256. STRING_CASE(RNS_DOES_NOT_EXIST);
  257. STRING_CASE(RNS_DELETED);
  258. STRING_CASE(RNS_NOT_RECONCILED);
  259. STRING_CASE(RNS_UP_TO_DATE);
  260. STRING_CASE(RNS_CHANGED);
  261. default:
  262. ERROR_OUT((TEXT("GetRECNODESTATEString() called on unknown RECNODESTATE %d."),
  263. rnstate));
  264. pcsz = TEXT("UNKNOWN RECNODESTATE");
  265. break;
  266. }
  267. ASSERT(IS_VALID_STRING_PTR(pcsz, CSTR));
  268. return(pcsz);
  269. }
  270. /*
  271. ** GetRECNODEACTIONString()
  272. **
  273. **
  274. **
  275. ** Arguments:
  276. **
  277. ** Returns:
  278. **
  279. ** Side Effects: none
  280. */
  281. PUBLIC_CODE LPCTSTR GetRECNODEACTIONString(RECNODEACTION rnaction)
  282. {
  283. LPCTSTR pcsz;
  284. switch (rnaction)
  285. {
  286. STRING_CASE(RNA_NOTHING);
  287. STRING_CASE(RNA_COPY_FROM_ME);
  288. STRING_CASE(RNA_COPY_TO_ME);
  289. STRING_CASE(RNA_MERGE_ME);
  290. STRING_CASE(RNA_DELETE_ME);
  291. default:
  292. ERROR_OUT((TEXT("GetRECNODEACTIONString() called on unknown RECNODEACTION %d."),
  293. rnaction));
  294. pcsz = TEXT("UNKNOWN RECNODEACTION");
  295. break;
  296. }
  297. ASSERT(IS_VALID_STRING_PTR(pcsz, CSTR));
  298. return(pcsz);
  299. }
  300. #endif /* __SYNCENG_H__ */
  301. #endif /* DEBUG */