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.

320 lines
6.1 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. faxlib.h
  5. Abstract:
  6. Fax driver library header file
  7. Environment:
  8. Fax driver, kernel and user mode
  9. Revision History:
  10. 01/09/96 -davidx-
  11. Created it.
  12. dd-mm-yy -author-
  13. description
  14. --*/
  15. #ifndef _FAXLIB_H_
  16. #define _FAXLIB_H_
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #if defined(UNICODE) && !defined(_UNICODE)
  21. #define _UNICODE
  22. #endif
  23. #include <stddef.h>
  24. #include <stdlib.h>
  25. #include <stdarg.h>
  26. #include <windef.h>
  27. #include <winerror.h>
  28. #include <winbase.h>
  29. #include <wingdi.h>
  30. #include <tchar.h>
  31. #include <shlobj.h>
  32. #include <fxsapip.h>
  33. #ifndef KERNEL_MODE
  34. #include <windows.h>
  35. #include <winspool.h>
  36. #include <stdio.h>
  37. #include <faxreg.h>
  38. #define FAXUTIL_ADAPTIVE
  39. #define FAXUTIL_DEBUG
  40. #include <faxutil.h>
  41. #else // !KERNEL_MODE
  42. #include <winddi.h>
  43. //
  44. // Nul terminator for a character string
  45. //
  46. #define NUL 0
  47. #define IsEmptyString(p) ((p)[0] == NUL)
  48. #define SizeOfString(p) ((_tcslen(p) + 1) * sizeof(TCHAR))
  49. #define IsNulChar(c) ((c) == NUL)
  50. #ifdef USERMODE_DRIVER
  51. #include <windows.h>
  52. #include <winspool.h>
  53. #define FAXUTIL_ADAPTIVE
  54. #define FAXUTIL_DEBUG
  55. #include <faxutil.h>
  56. #endif
  57. #endif
  58. #include "devmode.h"
  59. #include "prndata.h"
  60. #include "registry.h"
  61. #define AllocString(cch) MemAlloc(sizeof(TCHAR) * (cch))
  62. #define AllocStringZ(cch) MemAllocZ(sizeof(TCHAR) * (cch))
  63. //
  64. // Result of string comparison
  65. //
  66. #define EQUAL_STRING 0
  67. //
  68. // Maximum value for signed and unsigned integers
  69. //
  70. #ifndef MAX_LONG
  71. #define MAX_LONG 0x7fffffff
  72. #endif
  73. #ifndef MAX_DWORD
  74. #define MAX_DWORD 0xffffffff
  75. #endif
  76. #ifndef MAX_SHORT
  77. #define MAX_SHORT 0x7fff
  78. #endif
  79. #ifndef MAX_WORD
  80. #define MAX_WORD 0xffff
  81. #endif
  82. //
  83. // Path separator character
  84. //
  85. #define PATH_SEPARATOR '\\'
  86. //
  87. // Filename extension character
  88. //
  89. #define FILENAME_EXT '.'
  90. //
  91. // Deal with the difference between user and kernel mode functions
  92. //
  93. #if defined(KERNEL_MODE) && !defined(USERMODE_DRIVER)
  94. #define WritePrinter EngWritePrinter
  95. #define GetPrinterData EngGetPrinterData
  96. #define EnumForms EngEnumForms
  97. #define GetPrinter EngGetPrinter
  98. #define GetForm EngGetForm
  99. #define SetLastError EngSetLastError
  100. #define GetLastError EngGetLastError
  101. #define MulDiv EngMulDiv
  102. #define MemAlloc(size) EngAllocMem(0, size, DRIVER_SIGNATURE)
  103. #define MemAllocZ(size) EngAllocMem(FL_ZERO_MEMORY, size, DRIVER_SIGNATURE)
  104. #define MemFree(ptr) { if (ptr) EngFreeMem(ptr); }
  105. #else // !KERNEL_MODE
  106. #ifndef MemAlloc
  107. #define MemAlloc(size) ((PVOID) LocalAlloc(LPTR, (size)))
  108. #endif
  109. #ifndef MemAllocZ
  110. #define MemAllocZ(size) ((PVOID) MemAlloc((size)))
  111. #endif
  112. #ifndef MemFree
  113. #define MemFree(ptr) { if (ptr) LocalFree((HLOCAL) (ptr)); }
  114. #endif
  115. #endif
  116. //
  117. // Copy Unicode or ANSI string from source to destination
  118. //
  119. VOID
  120. CopyStringW(
  121. PWSTR pDest,
  122. PWSTR pSrc,
  123. INT destSize
  124. );
  125. VOID
  126. CopyStringA(
  127. PSTR pDest,
  128. PSTR pSrc,
  129. INT destSize
  130. );
  131. #ifdef UNICODE
  132. #define CopyString CopyStringW
  133. #else // !UNICODE
  134. #define CopyString CopyStringA
  135. #endif
  136. //
  137. // Make a duplicate of the given character string
  138. //
  139. LPTSTR
  140. DuplicateString(
  141. LPCTSTR pSrcStr
  142. );
  143. //
  144. // Strip the directory prefix from a filename (ANSI version)
  145. //
  146. PCSTR
  147. StripDirPrefixA(
  148. PCSTR pFilename
  149. );
  150. //
  151. // Wrapper function for GetPrinter spooler API
  152. //
  153. PVOID
  154. MyGetPrinter(
  155. HANDLE hPrinter,
  156. DWORD level
  157. );
  158. //
  159. // Wrapper function for GetPrinterDriver spooler API
  160. //
  161. PVOID
  162. MyGetPrinterDriver(
  163. HANDLE hPrinter,
  164. DWORD level
  165. );
  166. //
  167. // Wrapper function for GetPrinterDriverDirectory spooler API
  168. //
  169. LPTSTR
  170. MyGetPrinterDriverDirectory(
  171. LPTSTR pServerName,
  172. LPTSTR pEnvironment
  173. );
  174. //
  175. // These macros are used for debugging purposes. They expand
  176. // to white spaces on a free build. Here is a brief description
  177. // of what they do and how they are used:
  178. //
  179. // _debugLevel
  180. // A variable which controls the amount of debug messages. To generate
  181. // lots of debug messages, enter the following line in the debugger:
  182. //
  183. // ed _debugLevel 1
  184. //
  185. // Verbose
  186. // Display a debug message if VERBOSE is set to non-zero.
  187. //
  188. // Verbose(("Entering XYZ: param = %d\n", param));
  189. //
  190. // Error
  191. // Display an error message along with the filename and the line number
  192. // to indicate where the error occurred.
  193. //
  194. // Error(("XYZ failed"));
  195. //
  196. // ErrorIf
  197. // Display an error message if the specified condition is true.
  198. //
  199. // ErrorIf(error != 0, ("XYZ failed: error = %d\n", error));
  200. //
  201. // Assert
  202. // Verify a condition is true. If not, force a breakpoint.
  203. //
  204. // Assert(p != NULL && (p->flags & VALID));
  205. #if DBG
  206. extern ULONG __cdecl DbgPrint(CHAR *, ...);
  207. extern INT _debugLevel;
  208. #if defined(KERNEL_MODE) && !defined(USERMODE_DRIVER)
  209. #define DbgBreakPoint EngDebugBreak
  210. #else
  211. extern VOID DbgBreakPoint(VOID);
  212. #endif
  213. #define Warning(arg) {\
  214. DbgPrint("WRN %s (%d): ", StripDirPrefixA(__FILE__), __LINE__);\
  215. DbgPrint arg;\
  216. }
  217. #define Error(arg) {\
  218. DbgPrint("ERR %s (%d): ", StripDirPrefixA(__FILE__), __LINE__);\
  219. DbgPrint arg;\
  220. }
  221. #define Verbose(arg) { if (_debugLevel > 0) DbgPrint arg; }
  222. #define ErrorIf(cond, arg) { if (cond) Error(arg); }
  223. #define Assert(cond) {\
  224. if (! (cond)) {\
  225. DbgPrint("ASSERT: file %s, line %d\n", StripDirPrefixA(__FILE__), __LINE__);\
  226. DbgBreakPoint();\
  227. }\
  228. }
  229. #else // !DBG
  230. #define Verbose(arg)
  231. #define ErrorIf(cond, arg)
  232. #define Assert(cond)
  233. #define Warning(arg)
  234. #define Error(arg)
  235. #endif
  236. #ifdef __cplusplus
  237. }
  238. #endif
  239. #endif //!_FAXLIB_H_