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.

163 lines
4.0 KiB

  1. ///////////////////////////////////////////////////
  2. // fmlbpdm.c
  3. //
  4. // September.4,1997 H.Ishida (FPL)
  5. //
  6. // COPYRIGHT(C) FUJITSU LIMITED 1997
  7. #include "fmlbp.h"
  8. #include "fmdebug.h"
  9. #ifdef KERNEL_MODE
  10. #define SETLASTERROR(e) EngSetLastError(e)
  11. #else // !KERNEL_MODE
  12. #define SETLASTERROR(e) SetLastError(e)
  13. #endif // !KERNEL_MODE
  14. // MINI5 Export func.
  15. BOOL APIENTRY OEMGetInfo(DWORD dwInfo, PVOID pBuffer, DWORD cbSize, PDWORD pcbNeeded)
  16. {
  17. VERBOSE(("[OEMGetInfo]\r\n"))
  18. if(pcbNeeded == NULL){
  19. SETLASTERROR(ERROR_INVALID_PARAMETER);
  20. return FALSE;
  21. }
  22. *pcbNeeded = sizeof(DWORD);
  23. if(NULL == pBuffer || sizeof(DWORD) > cbSize){
  24. SETLASTERROR(ERROR_INSUFFICIENT_BUFFER);
  25. return FALSE;
  26. }
  27. switch(dwInfo){
  28. case OEMGI_GETSIGNATURE:
  29. VERBOSE(("OEMGI_GETSIGNATURE\r\n"))
  30. *(LPDWORD)pBuffer = FUFM_OEM_SIGNATURE;
  31. break;
  32. case OEMGI_GETINTERFACEVERSION:
  33. VERBOSE(("OEMGI_GETINTERFACEVERSION\r\n"))
  34. *(LPDWORD)pBuffer = PRINTER_OEMINTF_VERSION;
  35. break;
  36. case OEMGI_GETVERSION:
  37. VERBOSE(("OEMGI_GETVERSION\r\n"))
  38. *(LPDWORD)pBuffer = FUFM_OEM_VERSION;
  39. break;
  40. default:
  41. VERBOSE(("invalid dwInfo\r\n"))
  42. SETLASTERROR(ERROR_INVALID_PARAMETER);
  43. return FALSE;
  44. }
  45. return TRUE;
  46. }
  47. static BOOL BIsValidOEMDevModeParam(DWORD dwMode, POEMDMPARAM pOEMDevModeParam)
  48. {
  49. if(NULL == pOEMDevModeParam){
  50. VERBOSE(("pOEMDevModeParam is NULL\r\n"))
  51. return FALSE;
  52. }
  53. if(sizeof(OEMDMPARAM) > pOEMDevModeParam->cbSize){
  54. VERBOSE(("pOEMDevModeParam->cbSize (%d) is less than sizeof(OEMDMPARAM)\r\n", pOEMDevModeParam->cbSize))
  55. return FALSE;
  56. }
  57. if(NULL == pOEMDevModeParam->hPrinter){
  58. VERBOSE(("pOEMDevModeParam->hPrinter is NULL\r\n"))
  59. return FALSE;
  60. }
  61. if(NULL == pOEMDevModeParam->hModule){
  62. VERBOSE(("pOEMDevModeParam->hModule is NULL\r\n"))
  63. return FALSE;
  64. }
  65. if((0 != pOEMDevModeParam->cbBufSize) && (NULL == pOEMDevModeParam->pOEMDMOut)){
  66. VERBOSE(("pOEMDevModeParam->cbBufSize is not 0, and, pOEMDMOut is NULL\r\n"))
  67. return FALSE;
  68. }
  69. if((OEMDM_MERGE == dwMode) && (NULL == pOEMDevModeParam->pOEMDMIn)){
  70. VERBOSE(("dwMode is OEMDM_MERGE && pOEMDMIn is NULL\r\n"))
  71. return FALSE;
  72. }
  73. return TRUE;
  74. }
  75. static void fufmInitOEMExtraData(PFUFM_OEM_EXTRADATA pFufmOEMExtra)
  76. {
  77. pFufmOEMExtra->dmExtraHdr.dwSize = sizeof(FUFM_OEM_EXTRADATA);
  78. pFufmOEMExtra->dmExtraHdr.dwSignature = FUFM_OEM_SIGNATURE;
  79. pFufmOEMExtra->dmExtraHdr.dwVersion = FUFM_OEM_VERSION;
  80. }
  81. static void fufmMergeOEMExtraData(
  82. PFUFM_OEM_EXTRADATA pFufmOEMExtraIn,
  83. PFUFM_OEM_EXTRADATA pFufmOEMExtraOut)
  84. {
  85. }
  86. // MINI5 Export func.
  87. BOOL APIENTRY OEMDevMode(DWORD dwMode, POEMDMPARAM pOEMDevModeParam)
  88. {
  89. VERBOSE(("[OEMDevMode]\r\n"))
  90. if(BIsValidOEMDevModeParam(dwMode, pOEMDevModeParam) == FALSE){
  91. VERBOSE(("invalid OEMDevModeParam\r\n"))
  92. SETLASTERROR(ERROR_INVALID_PARAMETER);
  93. return FALSE;
  94. }
  95. if(dwMode == OEMDM_SIZE){
  96. pOEMDevModeParam->cbBufSize = sizeof(FUFM_OEM_EXTRADATA);
  97. VERBOSE(("OEMDM_SIZE %d\r\n", pOEMDevModeParam->cbBufSize))
  98. return TRUE;
  99. }
  100. if(sizeof(FUFM_OEM_EXTRADATA) > pOEMDevModeParam->cbBufSize){
  101. VERBOSE(("cbBufSize %d\r\n", pOEMDevModeParam->cbBufSize))
  102. SETLASTERROR(ERROR_INSUFFICIENT_BUFFER);
  103. return FALSE;
  104. }
  105. switch(dwMode){
  106. case OEMDM_DEFAULT:
  107. VERBOSE(("OEMDM_DEFAULT\r\n"));
  108. fufmInitOEMExtraData((PFUFM_OEM_EXTRADATA)pOEMDevModeParam->pOEMDMOut);
  109. break;
  110. case OEMDM_CONVERT:
  111. VERBOSE(("OEMDM_CONVERT\r\n"));
  112. fufmInitOEMExtraData((PFUFM_OEM_EXTRADATA)pOEMDevModeParam->pOEMDMOut);
  113. break;
  114. case OEMDM_MERGE:
  115. VERBOSE(("OEMDM_MERGE\r\n"));
  116. fufmMergeOEMExtraData((PFUFM_OEM_EXTRADATA)pOEMDevModeParam->pOEMDMIn,
  117. (PFUFM_OEM_EXTRADATA)pOEMDevModeParam->pOEMDMOut);
  118. break;
  119. default:
  120. VERBOSE(("invalid dwMode\r\n"));
  121. SETLASTERROR(ERROR_INVALID_PARAMETER);
  122. return FALSE;
  123. break;
  124. }
  125. return TRUE;
  126. }
  127. // end of fmlbpdm.c