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.

320 lines
7.0 KiB

  1. /*++
  2. Copyright (c) 1998-1999 Microsoft Corporation
  3. Module Name:
  4. minidrv.h
  5. Abstract:
  6. Common header file for Plug-in minidrivers.
  7. Environment:
  8. Windows NT printer drivers
  9. Revision History:
  10. --*/
  11. #ifndef _MINIDRV_H_
  12. #define _MINIDRV_H_
  13. #include <stddef.h>
  14. #include <stdlib.h>
  15. #include <objbase.h>
  16. #include <stdarg.h>
  17. #include <windef.h>
  18. #include <winerror.h>
  19. #include <winbase.h>
  20. #include <wingdi.h>
  21. #include <winddi.h>
  22. #include <tchar.h>
  23. #include <excpt.h>
  24. //
  25. // defined(KERNEL_MODE) Rendering module DLL in either kernel mode or user mode.
  26. // defined(KERNEL_MODE) & defined(USERMODE_DRIVER) User mode rendering DLL
  27. // !defined(KERNEL_MODE) UI module
  28. //
  29. #if defined(KERNEL_MODE) && !defined(USERMODE_DRIVER)
  30. // Kernel mode rendering DLL
  31. #include "winsplkm.h"
  32. #else
  33. // User mode DLL
  34. #include <winspool.h>
  35. #endif
  36. #if !defined(KERNEL_MODE)
  37. // UI DLL
  38. #include <windows.h>
  39. #include <compstui.h>
  40. #include <winddiui.h>
  41. #endif
  42. #if defined(USERMODE_DRIVER) || !defined(KERNEL_MODE)
  43. // UI DLL or User mode rendering DLL
  44. #include <stdio.h>
  45. #endif
  46. #ifdef __cplusplus
  47. extern "C" {
  48. #endif
  49. #ifdef WINNT_40
  50. //
  51. // The LONG_PTR is guaranteed to be the same size as a pointer. Its
  52. // size with change with pointer size (32/64). It should be used
  53. // anywhere that a pointer is cast to an integer type. ULONG_PTR is
  54. //
  55. typedef long LONG_PTR, *PLONG_PTR;
  56. typedef unsigned long ULONG_PTR, *PULONG_PTR;
  57. typedef int INT_PTR, *PINT_PTR;
  58. typedef unsigned int UINT_PTR, *PUINT_PTR;
  59. typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
  60. #define HandleToUlong( h ) ((ULONG) (h) )
  61. #define PtrToUlong( p ) ((ULONG) (p) )
  62. #define PtrToLong( p ) ((LONG) (p) )
  63. #define PtrToUshort( p ) ((unsigned short) (p) )
  64. #define PtrToShort( p ) ((short) (p) )
  65. #define GWLP_USERDATA GWL_USERDATA
  66. #define DWLP_USER DWL_USER
  67. #define DWLP_MSGRESULT 0
  68. #define SetWindowLongPtr SetWindowLong
  69. #define GetWindowLongPtr GetWindowLong
  70. #endif // WINNT_40
  71. #include <printoem.h>
  72. #include <prntfont.h>
  73. //
  74. // These macros are used for debugging purposes. They expand
  75. // to white spaces on a free build. Here is a brief description
  76. // of what they do and how they are used:
  77. //
  78. // giDebugLevel
  79. // Global variable which set the current debug level to control
  80. // the amount of debug messages emitted.
  81. //
  82. // VERBOSE(msg)
  83. // Display a message if the current debug level is <= DBG_VERBOSE.
  84. //
  85. // TERSE(msg)
  86. // Display a message if the current debug level is <= DBG_TERSE.
  87. //
  88. // WARNING(msg)
  89. // Display a message if the current debug level is <= DBG_WARNING.
  90. // The message format is: WRN filename (linenumber): message
  91. //
  92. // ERR(msg)
  93. // Similiar to WARNING macro above - displays a message
  94. // if the current debug level is <= DBG_ERROR.
  95. //
  96. // ASSERT(cond)
  97. // Verify a condition is true. If not, force a breakpoint.
  98. //
  99. // ASSERTMSG(cond, msg)
  100. // Verify a condition is true. If not, display a message and
  101. // force a breakpoint.
  102. //
  103. // RIP(msg)
  104. // Display a message and force a breakpoint.
  105. //
  106. // Usage:
  107. // These macros require extra parantheses for the msg argument
  108. // example, ASSERTMSG(x > 0, ("x is less than 0\n"));
  109. // WARNING(("App passed NULL pointer, ignoring...\n"));
  110. //
  111. #define DBG_VERBOSE 1
  112. #define DBG_TERSE 2
  113. #define DBG_WARNING 3
  114. #define DBG_ERROR 4
  115. #define DBG_RIP 5
  116. #if DBG
  117. extern INT giDebugLevel;
  118. #if defined(KERNEL_MODE) && !defined(USERMODE_DRIVER)
  119. extern VOID DbgPrint(PCSTR, ...);
  120. #define DbgBreakPoint EngDebugBreak
  121. #else
  122. extern ULONG _cdecl DbgPrint(PCSTR, ...);
  123. extern VOID DbgBreakPoint(VOID);
  124. #endif
  125. #define DBGMSG(level, prefix, msg) { \
  126. if (giDebugLevel <= (level)) { \
  127. DbgPrint("%s %s (%d): ", prefix, __FILE__, __LINE__); \
  128. DbgPrint msg; \
  129. } \
  130. }
  131. #define DBGPRINT(level, msg) { \
  132. if (giDebugLevel <= (level)) { \
  133. DbgPrint msg; \
  134. } \
  135. }
  136. #define VERBOSE(msg) DBGPRINT(DBG_VERBOSE, msg)
  137. #define TERSE(msg) DBGPRINT(DBG_TERSE, msg)
  138. #define WARNING(msg) DBGMSG(DBG_WARNING, "WRN", msg)
  139. #define ERR(msg) DBGMSG(DBG_ERROR, "ERR", msg)
  140. #ifndef __MDT__ // Don't redefine ASSERT when included in MINIDEV.EXE.
  141. #define ASSERT(cond) { \
  142. if (! (cond)) { \
  143. RIP(("\n")); \
  144. } \
  145. }
  146. #endif
  147. #define ASSERTMSG(cond, msg) { \
  148. if (! (cond)) { \
  149. RIP(msg); \
  150. } \
  151. }
  152. #define RIP(msg) { \
  153. DBGMSG(DBG_RIP, "RIP", msg); \
  154. DbgBreakPoint(); \
  155. }
  156. #else // !DBG
  157. #define VERBOSE(msg)
  158. #define TERSE(msg)
  159. #define WARNING(msg)
  160. #define ERR(msg)
  161. #ifndef __MDT__ // Don't redefine ASSERT when included in MINIDEV.EXE.
  162. #define ASSERT(cond)
  163. #endif
  164. #define ASSERTMSG(cond, msg)
  165. #define RIP(msg)
  166. #define DBGMSG(level, prefix, msg)
  167. #define DBGPRINT(level, msg)
  168. #endif
  169. //
  170. // The following macros let you enable tracing on per-file and per-function level.
  171. // To use these macros in a file, here is what you should do:
  172. //
  173. // At the beginning of the file (after header includes):
  174. //
  175. // Define a bit constant for each function you want to trace
  176. // Add the following line
  177. // DEFINE_FUNCTION_TRACE_FLAGS(flags);
  178. // where flags is a bit-wise OR of the functions you want to trace, e.g.
  179. // TRACE_FLAG_FUNC1 | TRACE_FLAG_FUNC2 | ...
  180. //
  181. // To generate trace inside each function you want to trace, use:
  182. // FUNCTION_TRACE(FunctionTraceFlag, (args));
  183. //
  184. #if DBG
  185. #define DEFINE_FUNCTION_TRACE_FLAGS(flags) \
  186. static DWORD gdwFunctionTraceFlags = (flags)
  187. #define FUNCTION_TRACE(flag, args) { \
  188. if (gdwFunctionTraceFlags & (flag)) { \
  189. DbgPrint args; \
  190. } \
  191. }
  192. #else // !DBG
  193. #define DEFINE_FUNCTION_TRACE_FLAGS(flags)
  194. #define FUNCTION_TRACE(flag, args)
  195. #endif // !DBG
  196. //
  197. // Memory allocation function macros
  198. //
  199. #define MemAlloc(size) ((PVOID) LocalAlloc(LMEM_FIXED, (size)))
  200. #define MemAllocZ(size) ((PVOID) LocalAlloc(LPTR, (size)))
  201. #define MemFree(p) { if (p) LocalFree((HLOCAL) (p)); }
  202. //
  203. // DBCS CharSet handling macros
  204. //
  205. //
  206. // 128: SHIFTJIS_CHARSET
  207. // 129: HANGEUL_CHARSET
  208. // 130: JOHAB_CHARSET (defined if WINVER >= 0x0400)
  209. // 134: GB2312_CHARSET
  210. // 136: CHINESEBIG5_CHARSET
  211. #define IS_DBCSCHARSET(j) \
  212. (((j) == SHIFTJIS_CHARSET) || \
  213. ((j) == HANGEUL_CHARSET) || \
  214. ((j) == JOHAB_CHARSET) || \
  215. ((j) == GB2312_CHARSET) || \
  216. ((j) == CHINESEBIG5_CHARSET))
  217. // 932: Japan
  218. // 936: Chinese (PRC, Singapore)
  219. // 949: Korean
  220. // 950: Chinese (China, Hong Kong SAR, Taiwan)
  221. // 1361: Korean (Johab)
  222. #define IS_DBCSCODEPAGE(j) \
  223. (((j) == 932) || \
  224. ((j) == 936) || \
  225. ((j) == 949) || \
  226. ((j) == 950) || \
  227. ((j) == 1361))
  228. //
  229. // The following are the resource types used in minidrivers and
  230. // used in the .rc file.
  231. //
  232. #define RC_TABLES 257
  233. #define RC_FONT 258
  234. #define RC_TRANSTAB 259
  235. //
  236. // 5.0 resource types
  237. //
  238. #define RC_UFM 260
  239. #define RC_GTT 261
  240. #define RC_HTPATTERN 264
  241. //
  242. // Internal resource type
  243. //
  244. #define RC_FD_GLYPHSET 262
  245. #ifdef __cplusplus
  246. }
  247. #endif
  248. #endif //_MINIDRV_H_