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.

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