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.

420 lines
10 KiB

  1. /*++
  2. Copyright (c) 1990-1995 Microsoft Corporation
  3. Module Name:
  4. debug.c
  5. Abstract:
  6. This module contains all debugging routines
  7. Author:
  8. 30-Aug-1995 Wed 19:01:07 created -by- Daniel Chou (danielc)
  9. [Environment:]
  10. NT Windows - Common Printer Driver UI DLL.
  11. [Notes:]
  12. Revision History:
  13. --*/
  14. #include "precomp.h"
  15. #pragma hdrstop
  16. #if DBG
  17. BOOL DoCPSUIWarn = TRUE;
  18. BOOL DoDbgMsg = TRUE;
  19. BOOL DoIntMsg = FALSE;
  20. LPSTR pTVOTName[] = { "TVOT_2STATES",
  21. "TVOT_3STATES",
  22. "TVOT_UDARROW",
  23. "TVOT_TRACKBAR",
  24. "TVOT_SCROLLBAR",
  25. "TVOT_LISTBOX",
  26. "TVOT_COMBOBOX",
  27. "TVOT_EDITBOX",
  28. "TVOT_PUSHBUTTON",
  29. "TVOT_CHKBOX" };
  30. LPSTR pDMPubName[] = { "DMPUB_NONE",
  31. "DMPUB_ORIENTATION",
  32. "DMPUB_SCALE",
  33. "DMPUB_COPIES_COLLATE",
  34. "DMPUB_DEFSOURCE",
  35. "DMPUB_PRINTQUALITY",
  36. "DMPUB_COLOR",
  37. "DMPUB_DUPLEX",
  38. "DMPUB_TTOPTION",
  39. "DMPUB_FORMNAME",
  40. "DMPUB_ICMMETHOD",
  41. "DMPUB_ICMINTENT",
  42. "DMPUB_MEDIATYPE",
  43. "DMPUB_DITHERTYPE",
  44. "DMPUB_OUTPUTBIN",
  45. "DMPUB_QUALITY",
  46. "DMPUB_NUP",
  47. "DMPUB_PAGEORDER",
  48. "<DMPUB_USER>"
  49. };
  50. VOID
  51. cdecl
  52. CPSUIDbgPrint(
  53. LPSTR pszFormat,
  54. ...
  55. )
  56. /*++
  57. Routine Description:
  58. This fucntion output the debug informat to the debugger
  59. Arguments:
  60. pszFormat - format string
  61. ... - variable data
  62. Return Value:
  63. VOID
  64. Author:
  65. 30-Aug-1995 Wed 19:10:34 updated -by- Daniel Chou (danielc)
  66. Revision History:
  67. --*/
  68. {
  69. va_list vaList;
  70. static WCHAR OutBuf[768];
  71. static WCHAR FormatBuf[256];
  72. //
  73. // We assume that UNICODE flag is turn on for the compilation, bug the
  74. // format string passed to here is ASCII version, so we need to convert
  75. // it to LPWSTR before the wvsprintf()
  76. //
  77. va_start(vaList, pszFormat);
  78. MultiByteToWideChar(CP_ACP, 0, pszFormat, -1, FormatBuf, ARRAYSIZE(FormatBuf));
  79. wvnsprintf(OutBuf, ARRAYSIZE(OutBuf) - 1, FormatBuf, vaList);
  80. va_end(vaList);
  81. OutputDebugString((LPTSTR)OutBuf);
  82. OutputDebugString(L"\n");
  83. }
  84. VOID
  85. CPSUIDbgType(
  86. INT Type
  87. )
  88. /*++
  89. Routine Description:
  90. this function output the ERROR/WARNING message
  91. Arguments:
  92. Type
  93. Return Value:
  94. Author:
  95. 30-Aug-1995 Wed 19:10:42 updated -by- Daniel Chou (danielc)
  96. Revision History:
  97. --*/
  98. {
  99. static WCHAR DebugDLLName[] = L"ComPstUI";
  100. if (Type) {
  101. OutputDebugString((Type < 0) ? L"ERROR: " : L"WARNING: ");
  102. }
  103. OutputDebugString(DebugDLLName);
  104. OutputDebugString(L": ");
  105. }
  106. VOID
  107. _CPSUIAssert(
  108. LPSTR pMsg,
  109. LPSTR pFalseExp,
  110. LPSTR pFilename,
  111. UINT LineNo,
  112. LPVOID Exp,
  113. BOOL Stop
  114. )
  115. /*++
  116. Routine Description:
  117. This function output assertion message and false expression to the debugger
  118. then break into the debugger
  119. Arguments:
  120. pMsg - Message to displayed
  121. pFlaseExp - false expression
  122. pFilename - source filename
  123. LineNo - line number of the flase expression
  124. Return Value:
  125. VOID
  126. Author:
  127. 30-Aug-1995 Wed 19:10:49 updated -by- Daniel Chou (danielc)
  128. Revision History:
  129. --*/
  130. {
  131. OutputDebugString(L"\n");
  132. if ((pMsg) && (*pMsg)) {
  133. CPSUIDbgPrint(pMsg, Exp);
  134. }
  135. CPSUIDbgPrint("Assertion failed (%hs) in %hs line %u",
  136. pFalseExp, pFilename, LineNo);
  137. if (Stop) {
  138. DebugBreak();
  139. }
  140. }
  141. VOID
  142. CPSUIDbgShowItem(
  143. PTVWND pTVWnd,
  144. LPSTR pTitle,
  145. UINT Level,
  146. POPTITEM pItem
  147. )
  148. {
  149. if (pItem) {
  150. POPTTYPE pOptType;
  151. POPTPARAM pOptParam;
  152. PEXTCHKBOX pECB = pItem->pExtChkBox;
  153. UINT i;
  154. GSBUF_DEF(pItem, MAX_RES_STR_CHARS);
  155. if (pOptType = pItem->pOptType) {
  156. pOptParam = pOptType->pOptParam;
  157. } else {
  158. pOptParam = NULL;
  159. }
  160. CPSUIDbgPrint("\n---- %hs OPTITEM = %08lx -----", pTitle, pItem);
  161. CPSUIDbgPrint("cbSize = %ld", (DWORD)pItem->cbSize);
  162. CPSUIDbgPrint("pOptType = %08lx", pItem->pOptType);
  163. GSBUF_GETSTR(pItem->pName);
  164. CPSUIDbgPrint("pName = %ws", GSBUF_BUF);
  165. GSBUF_RESET;
  166. if ((pOptType) && (pOptParam)) {
  167. switch (pOptType->Type) {
  168. case TVOT_LISTBOX:
  169. case TVOT_2STATES:
  170. case TVOT_3STATES:
  171. case TVOT_COMBOBOX:
  172. if ((pItem->Sel < 0) || (pItem->Sel > pOptType->Count)) {
  173. GSBUF_GETSTR(pTVWnd->OptParamNone.pData);
  174. } else {
  175. GSBUF_GETSTR(pOptParam[pItem->Sel].pData);
  176. }
  177. break;
  178. case TVOT_EDITBOX:
  179. GSBUF_GETSTR(pItem->pSel);
  180. break;
  181. case TVOT_UDARROW:
  182. case TVOT_TRACKBAR:
  183. case TVOT_SCROLLBAR:
  184. case TVOT_PUSHBUTTON:
  185. case TVOT_CHKBOX:
  186. break;
  187. }
  188. }
  189. CPSUIDbgPrint("pSel = %ld, Name:<%ws> [%08lx]", pItem->pSel,
  190. GSBUF_BUF, pItem->pSel);
  191. CPSUIDbgPrint("UserData = %08lx", pItem->UserData);
  192. CPSUIDbgPrint("pExtChkBox = %08lx", pECB);
  193. if ((Level > 0) && (pECB)) {
  194. if (pItem->Flags & OPTIF_EXT_IS_EXTPUSH) {
  195. PEXTPUSH pEP = (PEXTPUSH)pECB;
  196. CPSUIDbgPrint(" ---- PEXTPUSH ----");
  197. CPSUIDbgPrint(" cbSize = %ld", (DWORD)pEP->cbSize);
  198. CPSUIDbgPrint(" Flags = %02lx", (DWORD)pEP->Flags);
  199. GSBUF_RESET;
  200. GSBUF_GETSTR(pEP->pTitle);
  201. CPSUIDbgPrint(" pTitle = %ws", GSBUF_BUF);
  202. CPSUIDbgPrint(" DlgProc/pfnCallBack = %08lx", pEP->DlgProc);
  203. CPSUIDbgPrint(" IconID = %0ld", pEP->IconID);
  204. CPSUIDbgPrint(" DlgTemplateID = %0ld", pEP->DlgTemplateID);
  205. CPSUIDbgPrint(" ~~~~~~~~~~~~~~~~~~~~");
  206. } else {
  207. CPSUIDbgPrint(" ---- PEXTCHKBOX ----");
  208. CPSUIDbgPrint(" cbSize = %ld", (DWORD)pECB->cbSize);
  209. CPSUIDbgPrint(" Flags = %02lx", (DWORD)pECB->Flags);
  210. GSBUF_RESET;
  211. GSBUF_GETSTR(pECB->pTitle);
  212. CPSUIDbgPrint(" pTitle = %ws", GSBUF_BUF);
  213. GSBUF_RESET;
  214. GSBUF_GETSTR(pECB->pSeparator);
  215. CPSUIDbgPrint(" pSeparator = %ws", GSBUF_BUF);
  216. GSBUF_RESET;
  217. GSBUF_GETSTR(pECB->pCheckedName);
  218. CPSUIDbgPrint(" pCheckBoxName = %ws", GSBUF_BUF);
  219. CPSUIDbgPrint(" IconID = %0ld", pECB->IconID);
  220. CPSUIDbgPrint(" ~~~~~~~~~~~~~~~~~~~~");
  221. }
  222. }
  223. if ((i = pItem->DMPubID) > DMPUB_LAST) {
  224. i = DMPUB_LAST + 1;
  225. }
  226. CPSUIDbgPrint("Flags = 0x%08lx", (DWORD)pItem->Flags);
  227. CPSUIDbgPrint("HelpIndex = %ld", (DWORD)pItem->HelpIndex);
  228. CPSUIDbgPrint("Level = %ld", (DWORD)pItem->Level);
  229. CPSUIDbgPrint("DMPubID = %hs (%ld)", pDMPubName[i], (DWORD)pItem->DMPubID);
  230. CPSUIDbgPrint("DlgPageIdx = %ld", (DWORD)pItem->DlgPageIdx);
  231. CPSUIDbgPrint("HTREEITEM = %08lx", _OI_HITEM(pItem));
  232. CPSUIDbgPrint("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  233. if ((Level > 0) && (pOptType)) {
  234. CPSUIDbgPrint(" ------- OPTTYPE --------");
  235. CPSUIDbgPrint(" cbSize = %ld", (DWORD)pOptType->cbSize);
  236. CPSUIDbgPrint(" Type = %hs", pTVOTName[pOptType->Type]);
  237. CPSUIDbgPrint(" Flags = %02lx", (DWORD)pOptType->Flags);
  238. CPSUIDbgPrint(" Count = %ld", (DWORD)pOptType->Count);
  239. CPSUIDbgPrint(" BegCtrlID = %ld", (DWORD)pOptType->BegCtrlID);
  240. CPSUIDbgPrint(" pOptParam = %08lx", pOptParam);
  241. CPSUIDbgPrint(" Style = %04lx", (DWORD)pOptType->Style);
  242. CPSUIDbgPrint(" ~~~~~~~~~~~~~~~~~~~~~~~~");
  243. if ((Level > 1) && (pOptParam)) {
  244. i = pOptType->Count;
  245. for (i = 0; i < (UINT)pOptType->Count; i++, pOptParam++) {
  246. GSBUF_RESET;
  247. GSBUF_GETSTR(pOptParam->pData);
  248. CPSUIDbgPrint(" ------- OPTPARAM %ld -------", (DWORD)i);
  249. CPSUIDbgPrint(" cbSize = %ld ", (DWORD)pOptParam->cbSize);
  250. CPSUIDbgPrint(" Flags = %02lx", (DWORD)pOptParam->Flags);
  251. CPSUIDbgPrint(" Style = %ld", (DWORD)pOptParam->Style);
  252. CPSUIDbgPrint(" pData = %ws (%08lx)", GSBUF_BUF, pOptParam->pData);
  253. CPSUIDbgPrint(" IconID = %ld", (DWORD)pOptParam->IconID);
  254. CPSUIDbgPrint(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  255. }
  256. }
  257. }
  258. CPSUIDbgPrint("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
  259. } else {
  260. CPSUIDbgPrint("\n\n---- %hs OPTITEM = %08lx -----", pTitle, pItem);
  261. }
  262. }
  263. #endif // DBG