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.

198 lines
5.5 KiB

  1. //-----------------------------------------------------------------------------
  2. // This files contains the module name for this mini driver. Each mini driver
  3. // must have a unique module name. The module name is used to obtain the
  4. // module handle of this Mini Driver. The module handle is used by the
  5. // generic library to load in tables from the Mini Driver.
  6. //
  7. // Copyright (C) 1994-1999 Microsoft Corporation
  8. //-----------------------------------------------------------------------------
  9. /*++
  10. Copyright (c) 1996-1999 Microsoft Corporation
  11. Module Name:
  12. cmdcb.c
  13. Abstract:
  14. Implementation of GPD command callback for "test.gpd":
  15. OEMCommandCallback
  16. Environment:
  17. Windows NT Unidrv driver
  18. Revision History:
  19. 04/07/97 -zhanw-
  20. Created it.
  21. --*/
  22. #include "pdev.h"
  23. #include <strsafe.h>
  24. #define WRITESPOOLBUF(p, s, n) \
  25. ((p)->pDrvProcs->DrvWriteSpoolBuf(p, s, n))
  26. //////////////////////////////////////////////////////////////////////////
  27. // Function: BInitOEMExtraData
  28. //
  29. // Description: Initializes OEM Extra data.
  30. //
  31. //
  32. // Parameters:
  33. //
  34. // pOEMExtra Pointer to a OEM Extra data.
  35. //
  36. // dwSize Size of OEM extra data.
  37. //
  38. //
  39. // Returns: TRUE if successful; FALSE otherwise.
  40. //
  41. //
  42. // Comments:
  43. //
  44. //
  45. // History:
  46. // 02/11/97 APresley Created.
  47. //
  48. //////////////////////////////////////////////////////////////////////////
  49. BOOL BInitOEMExtraData(POEM_EXTRADATA pOEMExtra)
  50. {
  51. // Initialize OEM Extra data.
  52. pOEMExtra->dmExtraHdr.dwSize = sizeof(OEM_EXTRADATA);
  53. pOEMExtra->dmExtraHdr.dwSignature = OEM_SIGNATURE;
  54. pOEMExtra->dmExtraHdr.dwVersion = OEM_VERSION;
  55. // Private Extention
  56. pOEMExtra->wMediaType = MEDIATYPE_PLAIN;
  57. pOEMExtra->wPrintQuality = PRINTQUALITY_NORMAL;
  58. pOEMExtra->wInputBin = INPUTBIN_AUTO;
  59. return TRUE;
  60. }
  61. //////////////////////////////////////////////////////////////////////////
  62. // Function: BMergeOEMExtraData
  63. //
  64. // Description: Validates and merges OEM Extra data.
  65. //
  66. //
  67. // Parameters:
  68. //
  69. // pdmIn pointer to an input OEM private devmode containing the settings
  70. // to be validated and merged. Its size is current.
  71. //
  72. // pdmOut pointer to the output OEM private devmode containing the
  73. // default settings.
  74. //
  75. //
  76. // Returns: TRUE if valid; FALSE otherwise.
  77. //
  78. //
  79. // Comments:
  80. //
  81. //
  82. // History:
  83. // 02/11/97 APresley Created.
  84. // 04/08/97 ZhanW Modified the interface
  85. //
  86. //////////////////////////////////////////////////////////////////////////
  87. BOOL BMergeOEMExtraData(
  88. POEM_EXTRADATA pdmIn,
  89. POEM_EXTRADATA pdmOut
  90. )
  91. {
  92. if(pdmIn) {
  93. //
  94. // copy over the private fields, if they are valid
  95. //
  96. pdmOut->wMediaType = pdmIn->wMediaType;
  97. pdmOut->wPrintQuality = pdmIn->wPrintQuality;
  98. pdmOut->wInputBin= pdmIn->wInputBin;
  99. }
  100. return TRUE;
  101. }
  102. // #######
  103. /*****************************************************************************/
  104. /* */
  105. /* INT APIENTRY OEMCommandCallback( */
  106. /* PDEVOBJ pdevobj */
  107. /* DWORD dwCmdCbId */
  108. /* DWORD dwCount */
  109. /* PDWORD pdwParams */
  110. /* */
  111. /*****************************************************************************/
  112. INT APIENTRY
  113. OEMCommandCallback(
  114. PDEVOBJ pdevobj, // Points to private data required by the Unidriver.dll
  115. DWORD dwCmdCbId, // Callback ID
  116. DWORD dwCount, // Counts of command parameter
  117. PDWORD pdwParams) // points to values of command params
  118. {
  119. POEM_EXTRADATA pOEM = (POEM_EXTRADATA)(pdevobj->pOEMDM);
  120. BYTE ESC_PRINT_MODE[] = "\x1B\x28\x63\x03\x00\x10\x00\x00";
  121. BYTE ESC_INPUTBIN[] = "\x1B\x28\x6C\x02\x00\x00\x00";
  122. switch(dwCmdCbId)
  123. {
  124. case CMD_BEGIN_PAGE:
  125. // Check the index of array
  126. // NTRAID#NTBUG9-577887-2002/03/15-shimm-
  127. if (pOEM->wPrintQuality >= NUM_QUALITY) goto error;
  128. if (pOEM->wMediaType >= NUM_MEDIA) goto error;
  129. // Set Print mode setting command parameter
  130. ESC_PRINT_MODE[6] =
  131. bPrintModeParamTable[pOEM->wPrintQuality][pOEM->wMediaType];
  132. // Set input bin command parameter
  133. ESC_INPUTBIN[5] = (pOEM->wInputBin == INPUTBIN_AUTO ? 0x14 : 0x11);
  134. ESC_INPUTBIN[6] = bInputBinMediaParamTable[pOEM->wMediaType];
  135. WRITESPOOLBUF(pdevobj, (PBYTE)ESC_PRINT_MODE, 8);
  136. WRITESPOOLBUF(pdevobj, (PBYTE)ESC_INPUTBIN,7 );
  137. break;
  138. // Media Type
  139. case CMD_MEDIA_PLAIN:
  140. case CMD_MEDIA_COAT:
  141. case CMD_MEDIA_OHP:
  142. case CMD_MEDIA_BPF:
  143. case CMD_MEDIA_FABRIC:
  144. case CMD_MEDIA_GLOSSY:
  145. case CMD_MEDIA_HIGHGLOSS:
  146. case CMD_MEDIA_HIGHRESO:
  147. pOEM->wMediaType = (WORD)(dwCmdCbId - MEDIATYPE_START);
  148. break;
  149. // Print Quality
  150. case CMD_QUALITY_NORMAL:
  151. case CMD_QUALITY_HIGHQUALITY:
  152. case CMD_QUALITY_DRAFT:
  153. pOEM->wPrintQuality = (WORD)(dwCmdCbId - PRINTQUALITY_START);
  154. break;
  155. case CMD_INPUTBIN_AUTO:
  156. pOEM->wInputBin = INPUTBIN_AUTO;
  157. break;
  158. case CMD_INPUTBIN_MANUAL:
  159. pOEM->wInputBin = INPUTBIN_MANUAL;
  160. break;
  161. default:
  162. break;
  163. }
  164. return 0;
  165. error:
  166. return -1;
  167. }