Source code of Windows XP (NT5)
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.

302 lines
5.9 KiB

  1. /******************** Function Prototypes file ***************************
  2. * libproto.h
  3. * Function prototypes for NT printer drivers library. Also includes
  4. * a brief description of the function.
  5. *
  6. * 11:04 on Wed 14 Nov 1990 -by- Lindsay Harris [lindsayh]
  7. *
  8. * Copyright (C) Microsoft Corporation, 1990 - 1992
  9. *
  10. ************************************************************************/
  11. #ifndef __LIBPROTO_H__
  12. #define __LIBPROTO_H__
  13. #if defined(NTGDIKM) && !defined(KERNEL_MODE)
  14. #define KERNEL_MODE
  15. #endif
  16. #ifdef NTGDIKM
  17. extern ULONG gulMemID;
  18. #define DbgPrint DrvDbgPrint
  19. #define HeapAlloc(hHeap,Flags,Size) DRVALLOC( Size )
  20. #define HeapFree( hHeap, Flags, VBits ) DRVFREE( VBits )
  21. #ifndef FillMemory
  22. #define FillMemory(Destination,Length,Fill) memset((Destination),(Fill),(Length))
  23. #endif
  24. //#define DRVALLOC(c) EngAllocMem(0, c,gulMemID)
  25. //#define DRVFREE(p) EngFreeMem(p)
  26. #endif
  27. /*
  28. * Until there is proper error logging:-
  29. * WinSetError( "String" );
  30. * The String appears on the debug terminal. A \n is appended.
  31. */
  32. void WinSetError( LPSTR );
  33. /*
  34. * Function to add a copy of a string to a heap. Returns address of copy
  35. * of string (if successful) or 0 if memory cannot be allocated.
  36. */
  37. LPSTR StrToHeap( HANDLE, LPSTR );
  38. PWSTR StrToWHeap( HANDLE, LPSTR ); /* Expand to Wide too! */
  39. PWSTR WstrToHeap( HANDLE, PWSTR ); /* WIDE version */
  40. /*
  41. * Convert an ascii style string to WCHAR format, appending it to the
  42. * end of the wchar passed in. Returns value of first parameter.
  43. */
  44. PWSTR strcat2WChar( PWSTR, LPSTR );
  45. /*
  46. * Convert an ascii style string to WCHAR format, copying it to the
  47. * wchar passed in. Returns value of first parameter.
  48. */
  49. PWSTR strcpy2WChar( PWSTR, LPSTR );
  50. /*
  51. * The WCHAR world's equivalent of strlen(): returns the number of WCHARs
  52. * in the string passed in.
  53. */
  54. int wchlen( PWSTR );
  55. /*
  56. * Concatenate a PWSTR to another. Returns address of destination.
  57. */
  58. PWSTR wchcat( PWSTR, PWSTR );
  59. /*
  60. * Copy a PWSTR to another. Returns address of destination.
  61. */
  62. PWSTR wchcpy( PWSTR, PWSTR );
  63. PVOID MapFile(PWSTR);
  64. #if NTGDIKM
  65. /*
  66. * check if two strings are identical
  67. */
  68. BOOL bSameStringW(
  69. PWCHAR pwch1,
  70. PWCHAR pwch2);
  71. /*
  72. * Some system function prototypes have vanished - replace them here.
  73. */
  74. void DrvDbgPrint( char *, ... );
  75. #if DBG
  76. #define RIP(x) {DrvDbgPrint((PSZ)(x)); EngDebugBreak();}
  77. #define WARNING(s) DrvDbgPrint("warning: %s",(PSZ)(s))
  78. BOOL
  79. SetAllocCounters(
  80. VOID
  81. );
  82. #else
  83. #define RIP(x)
  84. #define WARNING(s)
  85. #endif
  86. LPVOID
  87. DRVALLOC(
  88. DWORD cbAlloc
  89. );
  90. BOOL
  91. DRVFREE(
  92. LPVOID pMem
  93. );
  94. #else //NTGDIKM
  95. /*
  96. * Break into the debugger - Ye olde RIP.
  97. */
  98. VOID DoRip( LPSTR );
  99. #if DBG
  100. #define WARNING(s) DbgPrint("warning: %s",(PSZ)(s))
  101. #ifdef FIREWALLS
  102. #define RIP(x) DoRip( (PSZ)(x) )
  103. #else
  104. #define RIP(x) {DbgPrint((PSZ)(x)); DbgBreakPoint();}
  105. #endif
  106. #else
  107. #define WARNING(s)
  108. #define RIP(x)
  109. #endif //DBG
  110. //
  111. // Define kernel debugger print prototypes and macros.
  112. // These are defined in ntrtl.h which we should include
  113. // instead. For now, redefine them here to avoid breaking
  114. // other components.
  115. //
  116. #if DBG
  117. VOID
  118. NTAPI
  119. DbgBreakPoint(
  120. VOID
  121. );
  122. ULONG
  123. __cdecl
  124. DbgPrint(
  125. PCH Format,
  126. ...
  127. );
  128. #endif
  129. PVOID MapFile(PWSTR);
  130. #endif //NTGDIKM
  131. /*
  132. * A simplified write function. Returns TRUE if the WriteFile()
  133. * call returns TRUE and the number of bytes written equals the
  134. * number requested.
  135. *
  136. * bWrite( file_handle, address_of_data, number_of_bytes );
  137. */
  138. BOOL bWrite( HANDLE, void *, int );
  139. /*
  140. * Function to copy the contents of one file to another. The files
  141. * are referenced via file handles. No positioning is done - that is
  142. * up to the user.
  143. * The second form also allows a byte count to limit the amount of data
  144. * copied.
  145. */
  146. long lFICopy( HANDLE, HANDLE );
  147. long lFInCopy( HANDLE, HANDLE, long );
  148. /*
  149. * Spooler interaction functions. These allow drivers to call the
  150. * spooler directly, without going through engine stub functions.
  151. */
  152. BOOL bSplGetFormW( HANDLE, PWSTR, DWORD, BYTE *, DWORD, DWORD * );
  153. DWORD dwSplGetPrinterDataW( HANDLE, PWSTR, BYTE *, DWORD, DWORD * );
  154. BOOL bSplWrite( HANDLE, ULONG, VOID * );
  155. /* Function needed to allow the driver to reach the spooler */
  156. BOOL bImpersonateClient( void );
  157. /************************** HACK ***************************************
  158. * The following function is only required until the DEVMODE contains
  159. * a form name rather than an index. And even then it might be required.
  160. *
  161. ***********************************************************************/
  162. char *_IndexToName( int );
  163. //
  164. // COLORADJUSTMENT validating
  165. //
  166. BOOL
  167. ValidateColorAdj(
  168. PCOLORADJUSTMENT pca
  169. );
  170. // Generic devmode conversion routine
  171. LONG
  172. ConvertDevmode(
  173. PDEVMODE pdmIn,
  174. PDEVMODE pdmOut
  175. );
  176. #ifndef KERNEL_MODE
  177. // Copy DEVMODE to an output buffer before return to the
  178. // caller of DrvDocumentProperties
  179. BOOL
  180. ConvertDevmodeOut(
  181. PDEVMODE pdmSrc,
  182. PDEVMODE pdmIn,
  183. PDEVMODE pdmOut
  184. );
  185. // Library routine to handle common cases of DrvConvertDevmode
  186. typedef struct {
  187. WORD dmDriverVersion; // current driver version
  188. WORD dmDriverExtra; // size of current version private devmode
  189. WORD dmDriverVersion351; // 3.51 driver version
  190. WORD dmDriverExtra351; // size of 3.51 version private devmode
  191. } DRIVER_VERSION_INFO, *PDRIVER_VERSION_INFO;
  192. #define CDM_RESULT_FALSE 0
  193. #define CDM_RESULT_TRUE 1
  194. #define CDM_RESULT_NOT_HANDLED 2
  195. INT
  196. CommonDrvConvertDevmode(
  197. PWSTR pPrinterName,
  198. PDEVMODE pdmIn,
  199. PDEVMODE pdmOut,
  200. PLONG pcbNeeded,
  201. DWORD fMode,
  202. PDRIVER_VERSION_INFO pDriverVersions
  203. );
  204. UINT
  205. cdecl
  206. DQPsprintf(
  207. HINSTANCE hInst,
  208. LPWSTR pwBuf,
  209. DWORD cchBuf,
  210. LPDWORD pcchNeeded,
  211. LPWSTR pwszFormat,
  212. ...
  213. );
  214. #endif // KERNEL_MODE
  215. #endif // !__LIBPROTO_H__