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.

816 lines
22 KiB

  1. /////////////////////////////////////////
  2. // fuxlres.c
  3. //
  4. // September.3,1997 H.Ishida (FPL)
  5. //
  6. // COPYRIGHT(C) FUJITSU LIMITED 1997
  7. // NTRAID#NTBUG9-553890-2002/03/22-yasuho-: mandatory changes (strsafe.h)
  8. // NTRAID#NTBUG9-589595-2002/03/29-v-kkon-: Possible buffer overrun
  9. #include "fuxl.h"
  10. #include "fuband.h"
  11. #include "fudebug.h"
  12. // for lib.h debug
  13. DWORD gdwDrvMemPoolTag = 'meoD';
  14. #define MIN_FREE_WIDTH_300 1063
  15. #define MAX_FREE_WIDTH_300 3390
  16. #define MIN_FREE_LENGTH_300 1630
  17. #define MAX_FREE_LENGTH_300 4843
  18. #define MIN_FREE_WIDTH_600 2126
  19. #define MAX_FREE_WIDTH_600 6780
  20. #define MIN_FREE_LENGTH_600 3260
  21. #define MAX_FREE_LENGTH_600 9686
  22. #define FUXL_UNKNOWN (DWORD)-1
  23. #define CMDID_ORIENTATION_PORTRAIT 20
  24. #define CMDID_ORIENTATION_LANDSCAPE 21
  25. #define CMDID_INPUTBIN_AUTO 30
  26. #define CMDID_INPUTBIN_MANUAL 31
  27. #define CMDID_INPUTBIN_BIN1 32
  28. #define CMDID_INPUTBIN_BIN2 33
  29. #define CMDID_INPUTBIN_BIN3 34
  30. #define CMDID_INPUTBIN_BIN4 35
  31. #define CMDID_RESOLUTION_300 40
  32. #define CMDID_RESOLUTION_600 41
  33. #define CMDID_FORM_A3 50
  34. #define CMDID_FORM_A4 51
  35. #define CMDID_FORM_A5 52
  36. #define CMDID_FORM_B4 53
  37. #define CMDID_FORM_B5 54
  38. #define CMDID_FORM_LETTER 55
  39. #define CMDID_FORM_LEGAL 56
  40. #define CMDID_FORM_JAPANESE_POSTCARD 57
  41. #define CMDID_FORM_CUSTOM_SIZE 58
  42. #define CMDID_START_JOB 60
  43. #define CMDID_END_JOB 61
  44. #define CMDID_START_DOC 70
  45. #define CMDID_END_DOC 71
  46. #define CMDID_START_PAGE 80
  47. #define CMDID_END_PAGE 81
  48. #define CMDID_COPIES 90
  49. #define CMDID_FF 100
  50. #define CMDID_CR 101
  51. #define CMDID_LF 102
  52. #define CMDID_SET_LINE_SPACING 103
  53. #define CMDID_X_MOVE 110
  54. #define CMDID_Y_MOVE 111
  55. #define CMDID_SEND_BLOCK_0 120
  56. #define CMDID_SEND_BLOCK_1 121
  57. #define CMDID_SIZEREDUCTION_100 130
  58. #define CMDID_SIZEREDUCTION_80 131
  59. #define CMDID_SIZEREDUCTION_70 132
  60. #define CMDID_SMOOTHING_OFF 140
  61. #define CMDID_SMOOTHING_ON 141
  62. #define CMDID_TONERSAVE_OFF 150
  63. #define CMDID_TONERSAVE_ON 151
  64. #define CMDID_DUPLEX_NONE 200
  65. #define CMDID_DUPLEX_VERTICAL 201
  66. #define CMDID_DUPLEX_HORIZONTAL 202
  67. #define CMDID_DUPLEX_POSITION_LEFTTOP 210
  68. #define CMDID_DUPLEX_POSITION_RIGHTBOTTOM 211
  69. #define CMDID_DUPLEX_WHITEPAGE_OFF 220
  70. #define CMDID_DUPLEX_WHITEPAGE_ON 221
  71. #define CMDID_DUPLEX_FRONTPAGE_MERGIN_0 300
  72. #define CMDID_DUPLEX_FRONTPAGE_MERGIN_30 330
  73. #define CMDID_DUPLEX_BACKPAGE_MERGIN_0 400
  74. #define CMDID_DUPLEX_BACKPAGE_MERGIN_30 430
  75. PBYTE fuxlPutULONG(PBYTE pb, size_t *cchCunt_p, ULONG ulData)
  76. {
  77. if(9 < ulData){
  78. pb = fuxlPutULONG(pb, cchCunt_p, ulData / 10);
  79. }
  80. if ((--(*cchCunt_p)) <= 0)
  81. return( NULL );
  82. if (pb)
  83. *pb++ = (BYTE)('0' + ulData % 10);
  84. return pb;
  85. }
  86. PBYTE fuxlPutLONG(PBYTE pb, size_t *cchCunt_p, LONG lData)
  87. {
  88. if(0 > lData){
  89. if ((--(*cchCunt_p)) <= 0)
  90. return( NULL );
  91. *pb++ = '-';
  92. lData = -lData;
  93. }
  94. return fuxlPutULONG(pb, cchCunt_p, (ULONG)lData);
  95. }
  96. BYTE fuxlGetHEX(int hi, int low)
  97. {
  98. DWORD dwData = 0;
  99. if('0' <= hi && hi <= '9')
  100. dwData += (hi - '0');
  101. else if('a' <= hi && hi <= 'f')
  102. dwData += (hi - 'a') + 10;
  103. else if('A' <= hi && hi <= 'F')
  104. dwData += (hi - 'A') + 10;
  105. dwData *= 10;
  106. if('0' <= low && low <= '9')
  107. dwData += (low - '0');
  108. else if('a' <= low && low <= 'f')
  109. dwData += (low - 'a') + 10;
  110. else if('A' <= low && low <= 'F')
  111. dwData += (low - 'A') + 10;
  112. return (BYTE)dwData;
  113. }
  114. // NTRAID#NTBUG9-589595-2002/03/29-v-kkon-: Possible buffer overrun
  115. LPBYTE _cdecl fuxlFormatCommand(LPBYTE pbCmd, size_t cchDest, LPCSTR pszFmt, ...)
  116. {
  117. LPCSTR pch;
  118. LPBYTE pb;
  119. size_t cchCunt, cchCunt_p;
  120. va_list arg;
  121. va_start(arg, pszFmt);
  122. pb = pbCmd;
  123. cchCunt = cchDest;
  124. for(pch = pszFmt; *pch != '\0'; ++pch){
  125. if(*pch == '%'){
  126. ++pch;
  127. switch(*pch){
  128. case 'd':
  129. if ((pb=fuxlPutLONG(pb, &cchCunt, va_arg(arg, LONG))) == NULL)
  130. return( NULL );
  131. break;
  132. case 'u':
  133. if ((pb=fuxlPutULONG(pb, &cchCunt, va_arg(arg, ULONG))) == NULL)
  134. return( NULL );
  135. break;
  136. case '%':
  137. if ((--cchCunt) <= 0)
  138. return( NULL );
  139. else
  140. *pb++ = '%';
  141. break;
  142. }
  143. }
  144. else if(*pch == '\\'){
  145. ++pch;
  146. switch(*pch){
  147. case 'r':
  148. case 'n':
  149. case 'f':
  150. case '0':
  151. case '\\':
  152. case 'x':
  153. if ((--cchCunt) <= 0)
  154. return( NULL );
  155. break;
  156. }
  157. switch(*pch){
  158. case 'r': *pb++ = '\x0d'; break;
  159. case 'n': *pb++ = '\x0a'; break;
  160. case 'f': *pb++ = '\x0c'; break;
  161. case '0': *pb++ = '\0'; break;
  162. case '\\': *pb++ = '\\'; break;
  163. case 'x': *pb++ = fuxlGetHEX(pch[1], pch[2]); pch += 2; break;
  164. }
  165. }
  166. else{
  167. *pb++ = *pch;
  168. }
  169. }
  170. va_end(arg);
  171. return pb;
  172. }
  173. void fuxlInitDevData(PFUXLDATA pData)
  174. {
  175. pData->dwResolution = FUXL_UNKNOWN;
  176. pData->dwCopies = FUXL_UNKNOWN;
  177. pData->dwSizeReduction = FUXL_UNKNOWN;
  178. pData->dwSmoothing = FUXL_UNKNOWN;
  179. pData->dwTonerSave = FUXL_UNKNOWN;
  180. pData->dwForm = FUXL_UNKNOWN;
  181. pData->dwPaperWidth = FUXL_UNKNOWN;
  182. pData->dwPaperLength = FUXL_UNKNOWN;
  183. pData->dwPaperOrientation = FUXL_UNKNOWN;
  184. pData->dwInputBin = FUXL_UNKNOWN;
  185. pData->dwDuplex = FUXL_UNKNOWN;
  186. pData->dwDuplexPosition = FUXL_UNKNOWN;
  187. pData->dwDuplexFrontPageMergin = FUXL_UNKNOWN;
  188. pData->dwDuplexBackPageMergin = FUXL_UNKNOWN;
  189. pData->dwDuplexWhitePage = FUXL_UNKNOWN;
  190. }
  191. void fuxlCmdStartJob(PDEVOBJ pdevobj)
  192. {
  193. TRACEOUT(("[fuxlCmdStartjob]\r\n"))
  194. WRITESPOOLBUF(pdevobj, "\x1b\x2f\xb2\x40\x7f\x1b\x7f\x00\x00\x01\x07", 11);
  195. }
  196. void fuxlCmdEndJob(PDEVOBJ pdevobj)
  197. {
  198. TRACEOUT(("[fuxlCmdEndJob]\r\n"))
  199. WRITESPOOLBUF(pdevobj, "\x1d\x30\x20\x41", 4);
  200. }
  201. static DWORD getFreeWidth(DWORD dwResolution, DWORD dwPaperWidth)
  202. {
  203. switch(dwResolution){
  204. case 300:
  205. if(dwPaperWidth < MIN_FREE_WIDTH_300)
  206. dwPaperWidth = MIN_FREE_WIDTH_300;
  207. else if(dwPaperWidth > MAX_FREE_WIDTH_300)
  208. dwPaperWidth = MAX_FREE_WIDTH_300;
  209. break;
  210. case 600:
  211. if(dwPaperWidth < MIN_FREE_WIDTH_600)
  212. dwPaperWidth = MIN_FREE_WIDTH_600;
  213. else if(dwPaperWidth > MAX_FREE_WIDTH_600)
  214. dwPaperWidth = MAX_FREE_WIDTH_600;
  215. break;
  216. default:
  217. TRACEOUT(("[getFreeLength]invalid resolution\r\n"))
  218. break;
  219. }
  220. return dwPaperWidth;
  221. }
  222. static DWORD getFreeLength(DWORD dwResolution, DWORD dwPaperLength)
  223. {
  224. switch(dwResolution){
  225. case 300:
  226. if(dwPaperLength < MIN_FREE_LENGTH_300)
  227. dwPaperLength = MIN_FREE_LENGTH_300;
  228. else if(dwPaperLength > MAX_FREE_LENGTH_300)
  229. dwPaperLength = MAX_FREE_LENGTH_300;
  230. break;
  231. case 600:
  232. if(dwPaperLength < MIN_FREE_LENGTH_600)
  233. dwPaperLength = MIN_FREE_LENGTH_600;
  234. else if(dwPaperLength > MAX_FREE_LENGTH_600)
  235. dwPaperLength = MAX_FREE_LENGTH_600;
  236. break;
  237. default:
  238. TRACEOUT(("[getFreeLength]invalid resolution\r\n"))
  239. break;
  240. }
  241. return dwPaperLength;
  242. }
  243. void fuxlCmdStartDoc(PDEVOBJ pdevobj)
  244. {
  245. PFUXLPDEV pFuxlPDEV;
  246. PCFUXLDATA pReq;
  247. PFUXLDATA pDev;
  248. PBYTE pbCmd;
  249. BYTE abCmd[256];
  250. BOOL bPaperCommandNeed;
  251. BOOL bDuplexChanged;
  252. DWORD dwSizeReduction;
  253. DWORD dwPaperWidth;
  254. DWORD dwPaperLength;
  255. TRACEOUT(("[fuxlCmdStartDoc]\r\n"))
  256. pFuxlPDEV = (PFUXLPDEV)pdevobj->pdevOEM;
  257. pReq = &pFuxlPDEV->reqData;
  258. pDev = &pFuxlPDEV->devData;
  259. pbCmd = abCmd;
  260. bPaperCommandNeed = FALSE;
  261. bDuplexChanged = FALSE;
  262. if(pDev->dwResolution != pReq->dwResolution ||
  263. pDev->dwPaperOrientation != pReq->dwPaperOrientation){
  264. // NTRAID#NTBUG9-156604-2002/03/22-yasuho-:
  265. // Should be perform Res command when orientation was changed.
  266. pDev->dwResolution = pReq->dwResolution;
  267. // NTRAID#NTBUG9-589595-2002/03/29-v-kkon-: Possible buffer overrun
  268. if( (pbCmd=fuxlFormatCommand(pbCmd, sizeof(abCmd),
  269. "\x1d%d C", pDev->dwResolution)) == NULL )
  270. return;
  271. }
  272. if(pDev->dwSmoothing != pReq->dwSmoothing){
  273. pDev->dwSmoothing = pReq->dwSmoothing;
  274. // NTRAID#NTBUG9-589595-2002/03/29-v-kkon-: Possible buffer overrun
  275. if( (pbCmd=fuxlFormatCommand(pbCmd, sizeof(abCmd),
  276. "\x1d%d D", pDev->dwSmoothing)) == NULL )
  277. return;
  278. }
  279. if(pDev->dwTonerSave != pReq->dwTonerSave){
  280. pDev->dwTonerSave = pReq->dwTonerSave;
  281. // NTRAID#NTBUG9-589595-2002/03/29-v-kkon-: Possible buffer overrun
  282. if( (pbCmd=fuxlFormatCommand(pbCmd, sizeof(abCmd),
  283. "\x1d%d E", pDev->dwTonerSave)) == NULL )
  284. return;
  285. }
  286. dwSizeReduction = pReq->dwSizeReduction;
  287. switch(pReq->dwForm){
  288. case FUXL_FORM_A5:
  289. case FUXL_FORM_LETTER:
  290. case FUXL_FORM_LEGAL:
  291. case FUXL_FORM_JAPANESE_POSTCARD:
  292. case FUXL_FORM_CUSTOM_SIZE:
  293. dwSizeReduction = 0;
  294. break;
  295. case FUXL_FORM_B5:
  296. if(dwSizeReduction != 0 && dwSizeReduction != 1)
  297. dwSizeReduction = 0;
  298. break;
  299. }
  300. if(pDev->dwSizeReduction != dwSizeReduction){
  301. pDev->dwSizeReduction = dwSizeReduction;
  302. // NTRAID#NTBUG9-589595-2002/03/29-v-kkon-: Possible buffer overrun
  303. if ( (pbCmd=fuxlFormatCommand(pbCmd, sizeof(abCmd),
  304. "\x1d%d F", pDev->dwSizeReduction)) == NULL)
  305. return;
  306. bPaperCommandNeed = TRUE;
  307. }
  308. if(pDev->dwForm != pReq->dwForm){
  309. pDev->dwForm = pReq->dwForm;
  310. bPaperCommandNeed = TRUE;
  311. }
  312. if(pDev->dwPaperOrientation != pReq->dwPaperOrientation){
  313. pDev->dwPaperOrientation = pReq->dwPaperOrientation;
  314. bPaperCommandNeed = TRUE;
  315. }
  316. if(pDev->dwForm != FUXL_FORM_CUSTOM_SIZE){
  317. if(pDev->dwInputBin != pReq->dwInputBin){
  318. pDev->dwInputBin = pReq->dwInputBin;
  319. bPaperCommandNeed = TRUE;
  320. }
  321. if(bPaperCommandNeed != FALSE){
  322. // NTRAID#NTBUG9-589595-2002/03/29-v-kkon-: Possible buffer overrun
  323. if( (pbCmd=fuxlFormatCommand(pbCmd, sizeof(abCmd),
  324. "\x1d%d;%d;%d;%d Q",
  325. HIWORD(pDev->dwForm),
  326. LOWORD(pDev->dwForm),
  327. pDev->dwInputBin,
  328. pDev->dwPaperOrientation)) == NULL )
  329. return;
  330. }
  331. }
  332. else{
  333. if(pDev->dwPaperOrientation == 0){
  334. dwPaperWidth = getFreeWidth(pDev->dwResolution, pReq->dwPaperWidth);
  335. dwPaperLength = getFreeLength(pDev->dwResolution, pReq->dwPaperLength);
  336. }
  337. else{
  338. dwPaperLength = getFreeWidth(pDev->dwResolution, pReq->dwPaperWidth);
  339. dwPaperWidth = getFreeLength(pDev->dwResolution, pReq->dwPaperLength);
  340. }
  341. if(pDev->dwPaperWidth != dwPaperWidth){
  342. pDev->dwPaperWidth = dwPaperWidth;
  343. bPaperCommandNeed = TRUE;
  344. }
  345. if(pDev->dwPaperLength != dwPaperLength){
  346. pDev->dwPaperLength = dwPaperLength;
  347. bPaperCommandNeed = TRUE;
  348. }
  349. if(pDev->dwInputBin != 9){
  350. pDev->dwInputBin = 9;
  351. bPaperCommandNeed = TRUE;
  352. }
  353. if(bPaperCommandNeed != FALSE){
  354. // NTRAID#NTBUG9-589595-2002/03/29-v-kkon-: Possible buffer overrun
  355. if( (pbCmd=fuxlFormatCommand(pbCmd, sizeof(abCmd),
  356. "\x1d%d;%d;%d;%d;%d Q",
  357. HIWORD(pDev->dwForm),
  358. pDev->dwPaperWidth,
  359. pDev->dwPaperLength,
  360. pDev->dwInputBin,
  361. pDev->dwPaperOrientation)) == NULL )
  362. return;
  363. }
  364. }
  365. if(pDev->dwCopies != pReq->dwCopies){
  366. pDev->dwCopies = pReq->dwCopies;
  367. // NTRAID#NTBUG9-589595-2002/03/29-v-kkon-: Possible buffer overrun
  368. if( (pbCmd=fuxlFormatCommand(pbCmd, sizeof(abCmd),
  369. "\x1d%d R", pDev->dwCopies)) == NULL )
  370. return;
  371. }
  372. if(pDev->dwDuplex != pReq->dwDuplex){
  373. bDuplexChanged = TRUE;
  374. pDev->dwDuplex = pReq->dwDuplex;
  375. }
  376. if(pDev->dwDuplex == 0){
  377. if(bDuplexChanged != FALSE){
  378. // NTRAID#NTBUG9-589595-2002/03/29-v-kkon-: Possible buffer overrun
  379. if( (pbCmd=fuxlFormatCommand(pbCmd, sizeof(abCmd), "\x1d\x30 G")) == NULL )
  380. return;
  381. }
  382. }
  383. else{
  384. if(pDev->dwDuplexPosition != pReq->dwDuplexPosition){
  385. bDuplexChanged = TRUE;
  386. pDev->dwDuplexPosition = pReq->dwDuplexPosition;
  387. }
  388. if(pDev->dwDuplexFrontPageMergin != pReq->dwDuplexFrontPageMergin){
  389. bDuplexChanged = TRUE;
  390. pDev->dwDuplexFrontPageMergin = pReq->dwDuplexFrontPageMergin;
  391. }
  392. if(pDev->dwDuplexBackPageMergin != pReq->dwDuplexBackPageMergin){
  393. bDuplexChanged = TRUE;
  394. pDev->dwDuplexBackPageMergin = pReq->dwDuplexBackPageMergin;
  395. }
  396. if(pDev->dwDuplexWhitePage != pReq->dwDuplexWhitePage){
  397. bDuplexChanged = TRUE;
  398. pDev->dwDuplexWhitePage = pReq->dwDuplexWhitePage;
  399. }
  400. if(bDuplexChanged != FALSE){
  401. // NTRAID#NTBUG9-589595-2002/03/29-v-kkon-: Possible buffer overrun
  402. if( (pbCmd=fuxlFormatCommand(pbCmd, sizeof(abCmd),
  403. "\x1d%u;%u;%u;%u;%u G",
  404. pDev->dwDuplex,
  405. pDev->dwDuplexPosition,
  406. pDev->dwDuplexFrontPageMergin,
  407. pDev->dwDuplexBackPageMergin,
  408. pDev->dwDuplexWhitePage)) == NULL )
  409. return;
  410. // NTRAID#NTBUG9-199308-2002/03/22-yasuho-: Duplex not work
  411. // NTRAID#NTBUG9-198813-2002/03/22-yasuho-: Duplex margins not work
  412. {
  413. DWORD dwDuplexCmd;
  414. DWORD dwFrontMargin, dwBackMargin;
  415. dwDuplexCmd = (pDev->dwDuplex - 1) * 2 +
  416. pDev->dwDuplexPosition;
  417. dwFrontMargin = (pDev->dwDuplexFrontPageMergin
  418. * pDev->dwResolution * 10) / 254;
  419. dwBackMargin = (pDev->dwDuplexBackPageMergin
  420. * pDev->dwResolution * 10) / 254;
  421. // NTRAID#NTBUG9-589595-2002/03/29-v-kkon-: Possible buffer overrun
  422. if( (pbCmd=fuxlFormatCommand(pbCmd, sizeof(abCmd),
  423. "\x1BQ2;%u;%u;%u!W",
  424. dwDuplexCmd,
  425. dwFrontMargin,
  426. dwBackMargin)) == NULL )
  427. return;
  428. }
  429. }
  430. }
  431. if(pbCmd > abCmd)
  432. WRITESPOOLBUF(pdevobj, abCmd, (DWORD)(pbCmd - abCmd));
  433. }
  434. void fuxlCmdEndDoc(PDEVOBJ pdevobj)
  435. {
  436. TRACEOUT(("[fuxlCmdEndJob]\r\n"))
  437. }
  438. void fuxlCmdStartPage(PDEVOBJ pdevobj)
  439. {
  440. PFUXLPDEV pFuxlPDEV;
  441. TRACEOUT(("[fuxlCmdStartPage]\r\n"))
  442. pFuxlPDEV = (PFUXLPDEV)pdevobj->pdevOEM;
  443. pFuxlPDEV->x = 0;
  444. pFuxlPDEV->y = 0;
  445. }
  446. void fuxlCmdEndPage(PDEVOBJ pdevobj)
  447. {
  448. TRACEOUT(("[fuxlCmdEndPage]\r\n"))
  449. }
  450. void fuxlCmdFF(PDEVOBJ pdevobj)
  451. {
  452. TRACEOUT(("[fuxlCmdFF]\r\n"))
  453. fuxlRefreshBand(pdevobj);
  454. }
  455. void fuxlCmdCR(PDEVOBJ pdevobj)
  456. {
  457. PFUXLPDEV pFuxlPDEV;
  458. TRACEOUT(("[fuxlCmdCR]\r\n"))
  459. pFuxlPDEV = (PFUXLPDEV)pdevobj->pdevOEM;
  460. pFuxlPDEV->x = 0;
  461. }
  462. void fuxlCmdLF(PDEVOBJ pdevobj)
  463. {
  464. PFUXLPDEV pFuxlPDEV;
  465. TRACEOUT(("[fuxlCmdLF]\r\n"))
  466. pFuxlPDEV = (PFUXLPDEV)pdevobj->pdevOEM;
  467. pFuxlPDEV->y += pFuxlPDEV->iLinefeedSpacing;
  468. }
  469. void fuxlCmdSetLinefeedSpacing(PDEVOBJ pdevobj, int iLinefeedSpacing)
  470. {
  471. PFUXLPDEV pFuxlPDEV;
  472. TRACEOUT(("[fuxlCmdSetLinefeedSpacing]%d\r\n", iLinefeedSpacing))
  473. pFuxlPDEV = (PFUXLPDEV)pdevobj->pdevOEM;
  474. pFuxlPDEV->iLinefeedSpacing = FUXL_MASTER_TO_DEVICE(pFuxlPDEV, iLinefeedSpacing);
  475. }
  476. INT fuxlCmdXMove(PDEVOBJ pdevobj, int x)
  477. {
  478. PFUXLPDEV pFuxlPDEV;
  479. TRACEOUT(("[fuxlCmdXMove] %d\r\n", x))
  480. pFuxlPDEV = (PFUXLPDEV)pdevobj->pdevOEM;
  481. pFuxlPDEV->x = FUXL_MASTER_TO_DEVICE(pFuxlPDEV, (int)x);
  482. if(pFuxlPDEV->x < 0)
  483. pFuxlPDEV->x = 0;
  484. return pFuxlPDEV->x;
  485. }
  486. INT fuxlCmdYMove(PDEVOBJ pdevobj, int y)
  487. {
  488. PFUXLPDEV pFuxlPDEV;
  489. TRACEOUT(("[fuxlCmdYMove] %d\r\n", y))
  490. pFuxlPDEV = (PFUXLPDEV)pdevobj->pdevOEM;
  491. pFuxlPDEV->y = FUXL_MASTER_TO_DEVICE(pFuxlPDEV, (int)y);
  492. if(pFuxlPDEV->y < 0)
  493. pFuxlPDEV->y = 0;
  494. return pFuxlPDEV->y;
  495. }
  496. void fuxlCmdSendBlock(PDEVOBJ pdevobj, DWORD dwCount, LPDWORD pdwParams, DWORD dwOutputCmd)
  497. {
  498. PFUXLPDEV pFuxlPDEV = (PFUXLPDEV)pdevobj->pdevOEM;
  499. TRACEOUT(("[fuxlCmdSendBlock]\r\n"))
  500. if(3 > dwCount){
  501. TRACEOUT(("Too less parameter %d\r\n", dwCount))
  502. return;
  503. }
  504. TRACEOUT(("cx %d cy %d\r\n", pdwParams[1] * 8, pdwParams[2]))
  505. pFuxlPDEV->dwOutputCmd = dwOutputCmd;
  506. pFuxlPDEV->cbBlockData = pdwParams[0];
  507. pFuxlPDEV->cBlockByteWidth = (int)pdwParams[1];
  508. pFuxlPDEV->cBlockHeight = (int)pdwParams[2];
  509. }
  510. // MINI5 Export func.
  511. INT APIENTRY OEMCommandCallback(
  512. PDEVOBJ pdevobj,
  513. DWORD dwCmdCbID,
  514. DWORD dwCount,
  515. PDWORD pdwParams)
  516. {
  517. PFUXLPDEV pFuxlPDEV;
  518. TRACEDDI(("[OEMCommandCallback]dwCmdCbID %d\r\n", dwCmdCbID))
  519. pFuxlPDEV = (PFUXLPDEV)pdevobj->pdevOEM;
  520. if(IS_VALID_FUXLPDEV(pFuxlPDEV) == FALSE)
  521. return 0;
  522. switch(dwCmdCbID){
  523. case CMDID_START_JOB: fuxlCmdStartJob(pdevobj); break;
  524. case CMDID_END_JOB: fuxlCmdEndJob(pdevobj); break;
  525. case CMDID_START_DOC: fuxlCmdStartDoc(pdevobj); break;
  526. case CMDID_END_DOC: fuxlCmdEndDoc(pdevobj); break;
  527. case CMDID_START_PAGE: fuxlCmdStartPage(pdevobj); break;
  528. case CMDID_END_PAGE: fuxlCmdEndPage(pdevobj); break;
  529. case CMDID_FF: fuxlCmdFF(pdevobj); break;
  530. case CMDID_CR: fuxlCmdCR(pdevobj); break;
  531. case CMDID_LF: fuxlCmdLF(pdevobj); break;
  532. case CMDID_SET_LINE_SPACING: fuxlCmdSetLinefeedSpacing(pdevobj, (int)pdwParams[0]); break;
  533. case CMDID_X_MOVE: return fuxlCmdXMove(pdevobj, (int)pdwParams[0]); // no break
  534. case CMDID_Y_MOVE: return fuxlCmdYMove(pdevobj, (int)pdwParams[0]); // no break
  535. case CMDID_SEND_BLOCK_0: fuxlCmdSendBlock(pdevobj, dwCount, pdwParams, OUTPUT_MH | OUTPUT_RTGIMG2); break;
  536. case CMDID_SEND_BLOCK_1: fuxlCmdSendBlock(pdevobj, dwCount, pdwParams, OUTPUT_MH2 | OUTPUT_RTGIMG4); break;
  537. case CMDID_RESOLUTION_300: pFuxlPDEV->reqData.dwResolution = 300; break;
  538. case CMDID_RESOLUTION_600: pFuxlPDEV->reqData.dwResolution = 600; break;
  539. case CMDID_ORIENTATION_PORTRAIT: pFuxlPDEV->reqData.dwPaperOrientation = 0; break;
  540. case CMDID_ORIENTATION_LANDSCAPE: pFuxlPDEV->reqData.dwPaperOrientation = 1; break;
  541. case CMDID_INPUTBIN_AUTO: pFuxlPDEV->reqData.dwInputBin = FUXL_INPUTBIN_AUTO; break;
  542. case CMDID_INPUTBIN_MANUAL: pFuxlPDEV->reqData.dwInputBin = FUXL_INPUTBIN_MANUAL; break;
  543. case CMDID_INPUTBIN_BIN1: pFuxlPDEV->reqData.dwInputBin = FUXL_INPUTBIN_BIN1; break;
  544. case CMDID_INPUTBIN_BIN2: pFuxlPDEV->reqData.dwInputBin = FUXL_INPUTBIN_BIN2; break;
  545. case CMDID_INPUTBIN_BIN3: pFuxlPDEV->reqData.dwInputBin = FUXL_INPUTBIN_BIN3; break;
  546. case CMDID_INPUTBIN_BIN4: pFuxlPDEV->reqData.dwInputBin = FUXL_INPUTBIN_BIN4; break;
  547. case CMDID_FORM_A3: pFuxlPDEV->reqData.dwForm = FUXL_FORM_A3; break;
  548. case CMDID_FORM_A4: pFuxlPDEV->reqData.dwForm = FUXL_FORM_A4; break;
  549. case CMDID_FORM_A5: pFuxlPDEV->reqData.dwForm = FUXL_FORM_A5; break;
  550. case CMDID_FORM_B4: pFuxlPDEV->reqData.dwForm = FUXL_FORM_B4; break;
  551. case CMDID_FORM_B5: pFuxlPDEV->reqData.dwForm = FUXL_FORM_B5; break;
  552. case CMDID_FORM_LETTER: pFuxlPDEV->reqData.dwForm = FUXL_FORM_LETTER; break;
  553. case CMDID_FORM_LEGAL: pFuxlPDEV->reqData.dwForm = FUXL_FORM_LEGAL; break;
  554. case CMDID_FORM_JAPANESE_POSTCARD: pFuxlPDEV->reqData.dwForm = FUXL_FORM_JAPANESE_POSTCARD; break;
  555. case CMDID_FORM_CUSTOM_SIZE: pFuxlPDEV->reqData.dwForm = FUXL_FORM_CUSTOM_SIZE; break;
  556. case CMDID_SIZEREDUCTION_100: pFuxlPDEV->reqData.dwSizeReduction = 0; break;
  557. case CMDID_SIZEREDUCTION_80: pFuxlPDEV->reqData.dwSizeReduction = 1; break;
  558. case CMDID_SIZEREDUCTION_70: pFuxlPDEV->reqData.dwSizeReduction = 2; break;
  559. case CMDID_SMOOTHING_OFF: pFuxlPDEV->reqData.dwSmoothing = 0; break;
  560. case CMDID_SMOOTHING_ON: pFuxlPDEV->reqData.dwSmoothing = 1; break;
  561. case CMDID_TONERSAVE_OFF: pFuxlPDEV->reqData.dwTonerSave = 0; break;
  562. case CMDID_TONERSAVE_ON: pFuxlPDEV->reqData.dwTonerSave = 1; break;
  563. case CMDID_DUPLEX_NONE: pFuxlPDEV->reqData.dwDuplex = 0; break;
  564. case CMDID_DUPLEX_VERTICAL: pFuxlPDEV->reqData.dwDuplex = 1; break;
  565. case CMDID_DUPLEX_HORIZONTAL: pFuxlPDEV->reqData.dwDuplex = 2; break;
  566. case CMDID_DUPLEX_POSITION_LEFTTOP: pFuxlPDEV->reqData.dwDuplexPosition = 0; break;
  567. case CMDID_DUPLEX_POSITION_RIGHTBOTTOM: pFuxlPDEV->reqData.dwDuplexPosition = 1; break;
  568. case CMDID_DUPLEX_WHITEPAGE_OFF: pFuxlPDEV->reqData.dwDuplexWhitePage = 0; break;
  569. case CMDID_DUPLEX_WHITEPAGE_ON: pFuxlPDEV->reqData.dwDuplexWhitePage = 1; break;
  570. // @Aug/31/98 ->
  571. case CMDID_COPIES:
  572. if (MAX_COPIES_VALUE < pdwParams[0]) {
  573. pFuxlPDEV->reqData.dwCopies = MAX_COPIES_VALUE;
  574. }
  575. else if(1 > pdwParams[0]) {
  576. pFuxlPDEV->reqData.dwCopies = 1;
  577. }
  578. else {
  579. pFuxlPDEV->reqData.dwCopies = pdwParams[0];
  580. }
  581. break;
  582. // @Aug/31/98 <-
  583. }
  584. if(CMDID_DUPLEX_FRONTPAGE_MERGIN_0 <= dwCmdCbID && dwCmdCbID <= CMDID_DUPLEX_FRONTPAGE_MERGIN_30){
  585. pFuxlPDEV->reqData.dwDuplexFrontPageMergin = dwCmdCbID - CMDID_DUPLEX_FRONTPAGE_MERGIN_0;
  586. }
  587. else if(CMDID_DUPLEX_BACKPAGE_MERGIN_0 <= dwCmdCbID && dwCmdCbID <= CMDID_DUPLEX_BACKPAGE_MERGIN_30){
  588. pFuxlPDEV->reqData.dwDuplexBackPageMergin = dwCmdCbID - CMDID_DUPLEX_BACKPAGE_MERGIN_0;
  589. }
  590. return 0;
  591. }
  592. // MINI5 Export func.
  593. PDEVOEM APIENTRY OEMEnablePDEV(
  594. PDEVOBJ pdevobj,
  595. PWSTR pPrinterName,
  596. ULONG cPatterns,
  597. HSURF* phsurfPatterns,
  598. ULONG cjGdiInfo,
  599. GDIINFO* pGdiInfo,
  600. ULONG cjDevInfo,
  601. DEVINFO* pDevInfo,
  602. DRVENABLEDATA* pded
  603. )
  604. {
  605. PFUXLPDEV pFuxlPDEV;
  606. TRACEDDI(("[OEMEnablePDEV]\r\n"));
  607. pFuxlPDEV = (PFUXLPDEV)MemAllocZ(sizeof(FUXLPDEV));
  608. if(pFuxlPDEV != NULL){
  609. pFuxlPDEV->dwSignature = FUXL_OEM_SIGNATURE;
  610. pFuxlPDEV->cbBlockData = 0;
  611. pFuxlPDEV->cBlockByteWidth = 0;
  612. pFuxlPDEV->cBlockHeight = 0;
  613. pFuxlPDEV->iLinefeedSpacing = 0;
  614. pFuxlPDEV->x = 0;
  615. pFuxlPDEV->y = 0;
  616. pFuxlPDEV->cxPage = pGdiInfo->ulHorzRes;
  617. pFuxlPDEV->cyPage = pGdiInfo->ulVertRes;
  618. TRACEOUT(("szlPhysSize %d, %d\r\n", pGdiInfo->szlPhysSize.cx, pGdiInfo->szlPhysSize.cy))
  619. TRACEOUT(("cxPage %d cyPage %d\r\n", pFuxlPDEV->cxPage, pFuxlPDEV->cyPage))
  620. fuxlInitDevData(&pFuxlPDEV->devData);
  621. fuxlInitDevData(&pFuxlPDEV->reqData);
  622. fuxlInitBand(pFuxlPDEV);
  623. }
  624. TRACEOUT(("[OEMEnablePDEV]exit\r\n"))
  625. return pFuxlPDEV;
  626. }
  627. // MINI5 Export func.
  628. VOID APIENTRY OEMDisablePDEV(PDEVOBJ pdevobj)
  629. {
  630. PFUXLPDEV pFuxlPDEV;
  631. TRACEDDI(("[OEMDisablePDEV]\r\n"));
  632. pFuxlPDEV = (PFUXLPDEV)pdevobj->pdevOEM;
  633. if(IS_VALID_FUXLPDEV(pFuxlPDEV) == FALSE)
  634. return;
  635. fuxlDisableBand(pFuxlPDEV);
  636. MemFree(pdevobj->pdevOEM);
  637. pdevobj->pdevOEM = NULL;
  638. }
  639. // MINI5 Export func.
  640. BOOL APIENTRY OEMResetPDEV(
  641. PDEVOBJ pdevobjOld,
  642. PDEVOBJ pdevobjNew
  643. )
  644. {
  645. PFUXLPDEV pFuxlPDEVOld;
  646. PFUXLPDEV pFuxlPDEVNew;
  647. TRACEDDI(("[OemResetPDEV]\r\n"))
  648. pFuxlPDEVOld = (PFUXLPDEV)pdevobjOld->pdevOEM;
  649. if(IS_VALID_FUXLPDEV(pFuxlPDEVOld) == FALSE)
  650. return FALSE;
  651. pFuxlPDEVNew = (PFUXLPDEV)pdevobjNew->pdevOEM;
  652. if(IS_VALID_FUXLPDEV(pFuxlPDEVNew) == FALSE)
  653. return FALSE;
  654. pFuxlPDEVNew->devData = pFuxlPDEVOld->devData;
  655. return TRUE;
  656. }
  657. // end of fuxlres.c