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.

147 lines
4.7 KiB

  1. /*=============================================================================
  2. * FILENAME: exports.cpp
  3. * Copyright (C) 1996-1998 HDE, Inc. All Rights Reserved. HDE Confidential.
  4. *
  5. * DESCRIPTION: Contains exported functions required to get an OEM plug-in
  6. * to work.
  7. * NOTES:
  8. *=============================================================================
  9. */
  10. #include <windows.h>
  11. #include <stdlib.h>
  12. #include <WINDDIUI.H>
  13. #include <PRINTOEM.H>
  14. #include <strsafe.h>
  15. #include "nc46nt.h"
  16. HINSTANCE ghInstance;
  17. /******************************************************************************
  18. * DESCRIPTION: Called by the postscript driver after the dll is loaded
  19. * to get plug-in information
  20. *
  21. *****************************************************************************/
  22. extern "C" BOOL APIENTRY
  23. OEMGetInfo( DWORD dwMode,
  24. PVOID pBuffer,
  25. DWORD cbSize,
  26. PDWORD pcbNeeded )
  27. {
  28. // Validate parameters.
  29. if( NULL == pcbNeeded )
  30. {
  31. SetLastError(ERROR_INVALID_PARAMETER);
  32. return FALSE;
  33. }
  34. // Set expected buffer size and number of bytes written.
  35. *pcbNeeded = sizeof(DWORD);
  36. // Check buffer size is sufficient.
  37. if((cbSize < *pcbNeeded) || (NULL == pBuffer))
  38. {
  39. SetLastError(ERROR_INSUFFICIENT_BUFFER);
  40. return FALSE;
  41. }
  42. switch(dwMode)
  43. {
  44. case OEMGI_GETSIGNATURE: // OEM DLL Signature
  45. *(PDWORD)pBuffer = OEM_SIGNATURE;
  46. break;
  47. case OEMGI_GETVERSION: // OEM DLL version
  48. *(PDWORD)pBuffer = OEM_VERSION;
  49. break;
  50. case OEMGI_GETINTERFACEVERSION: // version the Printer driver supports
  51. *(PDWORD)pBuffer = PRINTER_OEMINTF_VERSION;
  52. break;
  53. case OEMGI_GETPUBLISHERINFO: // fill PUBLISHERINFO structure
  54. // fall through to not supported
  55. default: // dwMode not supported.
  56. // Set written bytes to zero since nothing was written.
  57. *pcbNeeded = 0;
  58. SetLastError(ERROR_NOT_SUPPORTED);
  59. return FALSE;
  60. }
  61. return TRUE;
  62. }
  63. /******************************************************************************
  64. * DESCRIPTION: Exported function that allows setting of private and public
  65. * devmode fields.
  66. * NOTE: This function must be in entered under EXPORTS in rntapsui.def to be called
  67. *****************************************************************************/
  68. extern "C" BOOL APIENTRY
  69. OEMDevMode( DWORD dwMode, POEMDMPARAM pOemDMParam )
  70. {
  71. POEMDEV pOEMDevIn;
  72. POEMDEV pOEMDevOut;
  73. switch(dwMode) // user mode dll
  74. {
  75. case OEMDM_SIZE: // size of oem devmode
  76. if( pOemDMParam )
  77. pOemDMParam->cbBufSize = sizeof( OEMDEV );
  78. break;
  79. case OEMDM_DEFAULT: // fill oem devmode with default data
  80. if( pOemDMParam && pOemDMParam->pOEMDMOut )
  81. {
  82. pOEMDevOut = (POEMDEV)pOemDMParam->pOEMDMOut;
  83. pOEMDevOut->dmOEMExtra.dwSize = sizeof(OEMDEV);
  84. pOEMDevOut->dmOEMExtra.dwSignature = OEM_SIGNATURE;
  85. pOEMDevOut->dmOEMExtra.dwVersion = OEM_VERSION;
  86. // _tcscpy( pOEMDevOut->szUserName, TEXT("NO USER NAME") );
  87. StringCchCopy( pOEMDevOut->szUserName, NEC_USERNAME_BUF_LEN, TEXT("NO USER NAME") );
  88. }
  89. break;
  90. case OEMDM_MERGE: // set the public devmode fields
  91. case OEMDM_CONVERT: // convert any old oem devmode to new version
  92. if( pOemDMParam && pOemDMParam->pOEMDMOut && pOemDMParam->pOEMDMIn )
  93. {
  94. pOEMDevIn = (POEMDEV)pOemDMParam->pOEMDMIn;
  95. pOEMDevOut = (POEMDEV)pOemDMParam->pOEMDMOut;
  96. if( pOEMDevIn->dmOEMExtra.dwSignature == pOEMDevOut->dmOEMExtra.dwSignature )
  97. {
  98. TCHAR szUserName[NEC_USERNAME_BUF_LEN+2];
  99. DWORD dwCb = NEC_USERNAME_BUF_LEN;
  100. if( GetUserName( szUserName, &dwCb ) )
  101. StringCbCopy( pOEMDevOut->szUserName, sizeof(pOEMDevOut->szUserName), szUserName );
  102. }
  103. }
  104. break;
  105. }
  106. return( TRUE );
  107. }
  108. /******************************************************************************
  109. * DESCRIPTION: Windows dll required entry point function.
  110. *
  111. *****************************************************************************/
  112. extern "C"
  113. BOOL WINAPI DllMain(HINSTANCE hInst, WORD wReason, LPVOID lpReserved)
  114. {
  115. switch(wReason)
  116. {
  117. case DLL_PROCESS_ATTACH:
  118. ghInstance = hInst;
  119. break;
  120. case DLL_THREAD_ATTACH:
  121. break;
  122. case DLL_PROCESS_DETACH:
  123. break;
  124. case DLL_THREAD_DETACH:
  125. ghInstance = NULL;
  126. break;
  127. }
  128. return( TRUE );
  129. }