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.

410 lines
8.2 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. faxmon.h
  5. Abstract:
  6. Header file for fax print monitor
  7. Environment:
  8. Windows NT fax print monitor
  9. Revision History:
  10. 02/22/96 -davidx-
  11. Created it.
  12. dd-mm-yy -author-
  13. description
  14. --*/
  15. #ifndef _FAXMON_H_
  16. #define _FAXMON_H_
  17. #if defined(UNICODE) && !defined(_UNICODE)
  18. #define _UNICODE
  19. #endif
  20. #include <stddef.h>
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23. #include <windows.h>
  24. #include <winspool.h>
  25. #include <winsplp.h>
  26. #include <tchar.h>
  27. #include "winfax.h"
  28. #include "winfaxp.h"
  29. #include "jobtag.h"
  30. //
  31. // String resource IDs
  32. //
  33. #define IDS_FAX_MONITOR_NAME 256
  34. #define IDS_FAX_PORT_DESC 257
  35. #define IDS_PORT_ALREADY_EXISTS 258
  36. #define IDS_FAXERR_RECOVERABLE 259
  37. #define IDS_FAXERR_FATAL 260
  38. #define IDS_FAXERR_BAD_TIFF 261
  39. #define IDS_FAXERR_BAD_DATA16 262
  40. #define IDS_ADD_PORT 263
  41. #define IDS_DELETE_PORT 264
  42. #define IDS_CONFIGURE_PORT 265
  43. #define IDS_CONFIG_ERROR 266
  44. #define IDS_ADD_ERROR 267
  45. #define IDS_DELETE_ERROR 268
  46. //
  47. // Data structure for representing a fax monitor port
  48. //
  49. typedef struct _FAXPORT {
  50. PVOID startSig; // signature
  51. LPTSTR pName; // port name
  52. HANDLE hFaxSvc; // fax service handle
  53. DWORD jobId; // main job ID
  54. DWORD nextJobId; // next job ID in the chain
  55. HANDLE hFile; // handle to currently open file
  56. LPTSTR pFilename; // pointer to currently open file name
  57. LPTSTR pPrinterName; // currently connected printer name
  58. HANDLE hPrinter; // open handle to currently connected printer
  59. LPTSTR pParameters; // pointer to job parameter string
  60. FAX_JOB_PARAM jobParam; // pointer to individual job parameters
  61. HMODULE hWinFax; // handle for loaded winfax dll
  62. PFAXCONNECTFAXSERVERW pFaxConnectFaxServerW; // function pointer
  63. PFAXCLOSE pFaxClose; // function pointer
  64. PFAXSENDDOCUMENTW pFaxSendDocumentW; // function pointer
  65. PFAXACCESSCHECK pFaxAccessCheck; // function pointer
  66. PVOID endSig; // signature
  67. } FAXPORT, *PFAXPORT;
  68. #define ValidFaxPort(pFaxPort) \
  69. ((pFaxPort) && (pFaxPort) == (pFaxPort)->startSig && (pFaxPort) == (pFaxPort)->endSig)
  70. //
  71. // Different error code when sending fax document
  72. //
  73. #define FAXERR_NONE 0
  74. #define FAXERR_IGNORE 1
  75. #define FAXERR_RESTART 2
  76. #define FAXERR_SPECIAL 3
  77. #define FAXERR_FATAL IDS_FAXERR_FATAL
  78. #define FAXERR_RECOVERABLE IDS_FAXERR_RECOVERABLE
  79. #define FAXERR_BAD_TIFF IDS_FAXERR_BAD_TIFF
  80. #define FAXERR_BAD_DATA16 IDS_FAXERR_BAD_DATA16
  81. //
  82. // Memory allocation and deallocation macros
  83. //
  84. #define MemAlloc(size) ((PVOID) LocalAlloc(LMEM_FIXED, (size)))
  85. #define MemAllocZ(size) ((PVOID) LocalAlloc(LPTR, (size)))
  86. #define MemFree(ptr) { if (ptr) LocalFree((HLOCAL) (ptr)); }
  87. //
  88. // Number of tags used for passing fax job parameters
  89. //
  90. #define NUM_JOBPARAM_TAGS 11
  91. //
  92. // Nul terminator for a character string
  93. //
  94. #define NUL 0
  95. //
  96. // Result of string comparison
  97. //
  98. #define EQUAL_STRING 0
  99. #define IsEmptyString(p) ((p)[0] == NUL)
  100. #define IsNulChar(c) ((c) == NUL)
  101. #define SizeOfString(p) ((_tcslen(p) + 1) * sizeof(TCHAR))
  102. //
  103. // Maximum value for signed and unsigned integers
  104. //
  105. #ifndef MAX_LONG
  106. #define MAX_LONG 0x7fffffff
  107. #endif
  108. #ifndef MAX_DWORD
  109. #define MAX_DWORD 0xffffffff
  110. #endif
  111. #ifndef MAX_SHORT
  112. #define MAX_SHORT 0x7fff
  113. #endif
  114. #ifndef MAX_WORD
  115. #define MAX_WORD 0xffff
  116. #endif
  117. //
  118. // Path separator character
  119. //
  120. #define PATH_SEPARATOR '\\'
  121. //
  122. // Declaration of print monitor entry points
  123. //
  124. BOOL
  125. FaxMonOpenPort(
  126. LPTSTR pPortName,
  127. PHANDLE pHandle
  128. );
  129. BOOL
  130. FaxMonClosePort(
  131. HANDLE hPort
  132. );
  133. BOOL
  134. FaxMonStartDocPort(
  135. HANDLE hPort,
  136. LPTSTR pPrinterName,
  137. DWORD JobId,
  138. DWORD Level,
  139. LPBYTE pDocInfo
  140. );
  141. BOOL
  142. FaxMonEndDocPort(
  143. HANDLE hPort
  144. );
  145. BOOL
  146. FaxMonWritePort(
  147. HANDLE hPort,
  148. LPBYTE pBuffer,
  149. DWORD cbBuf,
  150. LPDWORD pcbWritten
  151. );
  152. BOOL
  153. FaxMonReadPort(
  154. HANDLE hPort,
  155. LPBYTE pBuffer,
  156. DWORD cbBuf,
  157. LPDWORD pcbRead
  158. );
  159. BOOL
  160. FaxMonEnumPorts(
  161. LPTSTR pServerName,
  162. DWORD Level,
  163. LPBYTE pPorts,
  164. DWORD cbBuf,
  165. LPDWORD pcbNeeded,
  166. LPDWORD pReturned
  167. );
  168. BOOL
  169. FaxMonAddPort(
  170. LPTSTR pServerName,
  171. HWND hwnd,
  172. LPTSTR pMonitorName
  173. );
  174. BOOL
  175. FaxMonAddPortEx(
  176. LPTSTR pServerName,
  177. DWORD level,
  178. LPBYTE pBuffer,
  179. LPTSTR pMonitorName
  180. );
  181. BOOL
  182. FaxMonDeletePort(
  183. LPTSTR pServerName,
  184. HWND hwnd,
  185. LPTSTR pPortName
  186. );
  187. BOOL
  188. FaxMonConfigurePort(
  189. LPWSTR pServerName,
  190. HWND hwnd,
  191. LPWSTR pPortName
  192. );
  193. //
  194. // Get the list of fax devices from the service
  195. //
  196. PFAX_PORT_INFO
  197. MyFaxEnumPorts(
  198. LPDWORD pcPorts,
  199. BOOL useCache
  200. );
  201. //
  202. // Wrapper function for fax service's FaxGetPort API
  203. //
  204. PFAX_PORT_INFO
  205. MyFaxGetPort(
  206. LPTSTR pPortName,
  207. BOOL useCache
  208. );
  209. //
  210. // Make a duplicate of the given character string
  211. //
  212. LPTSTR
  213. DuplicateString(
  214. LPCTSTR pSrcStr
  215. );
  216. //
  217. // Update the status information of a print job
  218. //
  219. BOOL
  220. SetJobStatus(
  221. HANDLE hPrinter,
  222. DWORD jobId,
  223. INT statusStrId
  224. );
  225. //
  226. // Wrapper function for spooler API GetJob
  227. //
  228. PVOID
  229. MyGetJob(
  230. HANDLE hPrinter,
  231. DWORD level,
  232. DWORD jobId
  233. );
  234. //
  235. // Create a temporary file in the system spool directory for storing fax data
  236. //
  237. LPTSTR
  238. CreateTempFaxFile(
  239. VOID
  240. );
  241. //
  242. // Open a handle to the current fax job file associated with a port
  243. //
  244. BOOL
  245. OpenTempFaxFile(
  246. PFAXPORT pFaxPort,
  247. BOOL doAppend
  248. );
  249. //
  250. // Process fax jobs sent from win31 and win95 clients
  251. //
  252. INT
  253. ProcessDownlevelFaxJob(
  254. PFAXPORT pFaxPort
  255. );
  256. //
  257. // Retrieve a DWORD value from the registry
  258. //
  259. DWORD
  260. GetRegistryDWord(
  261. HKEY hRegKey,
  262. LPTSTR pValueName,
  263. DWORD defaultValue
  264. );
  265. #define REGVAL_CONNECT_RETRY_COUNT TEXT("ConnectRetryCount")
  266. #define REGVAL_CONNECT_RETRY_INTERVAL TEXT("ConnectRetryInterval")
  267. #if DBG
  268. //
  269. // These macros are used for debugging purposes. They expand
  270. // to white spaces on a free build. Here is a brief description
  271. // of what they do and how they are used:
  272. //
  273. // _debugLevel
  274. // A variable which controls the amount of debug messages. To generate
  275. // lots of debug messages, enter the following line in the debugger:
  276. //
  277. // ed _debugLevel 1
  278. //
  279. // Verbose
  280. // Display a debug message if _debugLevel is set to non-zero.
  281. //
  282. // Verbose(("Entering XYZ: param = %d\n", param));
  283. //
  284. // Error
  285. // Display an error message along with the filename and the line number
  286. // to indicate where the error occurred.
  287. //
  288. // Error(("XYZ failed"));
  289. //
  290. // Assert
  291. // Verify a condition is true. If not, force a breakpoint.
  292. //
  293. // Assert(p != NULL && (p->flags & VALID));
  294. extern INT _debugLevel;
  295. extern VOID DbgPrint(LPCSTR, ...);
  296. extern LPCSTR StripDirPrefixA(LPCSTR);
  297. #define Warning(arg) {\
  298. DbgPrint("WRN %s (%d): ", StripDirPrefixA(__FILE__), __LINE__);\
  299. DbgPrint arg;\
  300. }
  301. #define Error(arg) {\
  302. DbgPrint("ERR %s (%d): ", StripDirPrefixA(__FILE__), __LINE__);\
  303. DbgPrint arg;\
  304. }
  305. #define Verbose(arg) { if (_debugLevel > 0) DbgPrint arg; }
  306. #define Assert(cond) {\
  307. if (! (cond)) {\
  308. DbgPrint("ASSERT: %s (%d)\n", StripDirPrefixA(__FILE__), __LINE__);\
  309. __try { \
  310. DebugBreak(); \
  311. } __except (UnhandledExceptionFilter(GetExceptionInformation())) { \
  312. } \
  313. }\
  314. }
  315. #define Trace(funcName) { if (_debugLevel > 0) DbgPrint("Entering %s ...\n", funcName); }
  316. #else // !DBG
  317. #define Verbose(arg)
  318. #define Assert(cond)
  319. #define Warning(arg)
  320. #define Error(arg)
  321. #define Trace(funcName)
  322. #endif // DBG
  323. #endif // !_FAXMON_H_