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.

219 lines
6.5 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. faxapi.h
  5. Abstract:
  6. This module contains all includes to the FAX client DLL. All
  7. objects in this DLL should include this header only.
  8. Author:
  9. Wesley Witt (wesw) 12-Jan-1996
  10. --*/
  11. #define _WINFAX_
  12. #include <windows.h>
  13. #include <shellapi.h>
  14. #include <winspool.h>
  15. #include <rpc.h>
  16. #include <tapi.h>
  17. #include <tapi3if.h>
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <tchar.h>
  21. #include <shlobj.h>
  22. #include "jobtag.h"
  23. #include "faxreg.h"
  24. #include "prtcovpg.h"
  25. #include "faxutil.h"
  26. #include "faxrpc.h"
  27. #include "faxcli.h"
  28. #include "faxext.h"
  29. #include "faxsvcrg.h"
  30. #include "rpcutil.h"
  31. #include "tiff.h"
  32. #include "tifflib.h"
  33. #include "fxsapip.h"
  34. #include "devmode.h"
  35. #include "shlwapi.h"
  36. #include "FaxRpcLimit.h"
  37. typedef enum
  38. {
  39. FHT_SERVICE, // Handle to server (FaxConnectFaxServer)
  40. FHT_PORT, // Port Handle (FaxOpenPort)
  41. FHT_MSGENUM // Message enumeration handle (FaxStartMessagesEnum)
  42. } FaxHandleType;
  43. #define TAPI_LIBRARY TEXT("%systemroot%\\system32\\tapi32.dll")
  44. #define ARGUMENT_PRESENT(ArgumentPointer) ((CHAR *)(ArgumentPointer) != (CHAR *)(NULL))
  45. #define FixupStringPtr(_buf,_str) \
  46. if (_str) \
  47. { \
  48. LPTSTR * lpptstr = (LPTSTR *)&(_str) ; \
  49. *lpptstr = (LPTSTR)((LPBYTE)(*(_buf)) + (ULONG_PTR)(_str)); \
  50. }
  51. #define FixupStringPtrW(_buf,_str) \
  52. if (_str) \
  53. { \
  54. LPWSTR * lppwstr = (LPWSTR *)&(_str) ; \
  55. *lppwstr = (LPWSTR)((LPBYTE)(*(_buf)) + (ULONG_PTR)(_str)); \
  56. }
  57. //
  58. // typedefs
  59. //
  60. typedef int (*FaxConnFunction)(LPTSTR,handle_t*);
  61. #define FH_PORT_HANDLE(_phe) (((PHANDLE_ENTRY)(_phe))->hGeneric)
  62. #define FH_MSG_ENUM_HANDLE(_phe) (((PHANDLE_ENTRY)(_phe))->hGeneric)
  63. #define FH_FAX_HANDLE(_phe) (((PHANDLE_ENTRY)(_phe))->FaxData->FaxHandle)
  64. #define FH_SERVER_VER(_phe) (((PHANDLE_ENTRY)(_phe))->FaxData->dwServerAPIVersion)
  65. #define FH_REPORTED_SERVER_VER(_phe) (((PHANDLE_ENTRY)(_phe))->FaxData->dwReportedServerAPIVersion)
  66. #define FH_CONTEXT_HANDLE(_phe) (((PHANDLE_ENTRY)(_phe))->FaxContextHandle)
  67. #define FH_DATA(_phe) (((PHANDLE_ENTRY)(_phe))->FaxData)
  68. #define ValidateFaxHandle(_phe,_type) ((_phe && \
  69. *(LPDWORD)_phe && \
  70. (((PHANDLE_ENTRY)_phe)->Type == _type)) ? TRUE : FALSE)
  71. typedef struct _FAX_HANDLE_DATA {
  72. HANDLE FaxHandle; // Fax handle obtained from FaxClientBindToFaxServer()
  73. LIST_ENTRY HandleTableListHead; //
  74. CRITICAL_SECTION CsHandleTable; // Critical section to protect concurrent access
  75. DWORD dwRefCount; // Usage reference counter
  76. LPTSTR MachineName; // The server machine name (NULL for local server)
  77. DWORD dwServerAPIVersion; // The API version of the server we're connected to (filtered)
  78. DWORD dwReportedServerAPIVersion; // The API version of the server we're connected to (non-filtered)
  79. BOOL bLocalConnection; // Indicates that this connection to fax server is local
  80. } FAX_HANDLE_DATA, *PFAX_HANDLE_DATA;
  81. typedef struct _HANDLE_ENTRY {
  82. LIST_ENTRY ListEntry; // linked list pointers
  83. FaxHandleType Type; // handle type, see FHT defines
  84. DWORD Flags; // open flags
  85. DWORD DeviceId; // device id
  86. PFAX_HANDLE_DATA FaxData; // pointer to connection data
  87. HANDLE hGeneric; // Generic handle to store
  88. HANDLE FaxContextHandle; // context handle for refcounting
  89. // (for FaxConnectFaxServer, obtained from FAX_ConnectionRefCount)
  90. } HANDLE_ENTRY, *PHANDLE_ENTRY;
  91. #define ASYNC_EVENT_INFO_SIGNATURE TEXT("KukiMuki")
  92. #define ASYNC_EVENT_INFO_SIGNATURE_LEN sizeof(ASYNC_EVENT_INFO_SIGNATURE)/sizeof(TCHAR)+1
  93. typedef struct _ASYNC_EVENT_INFO
  94. {
  95. TCHAR tszSignature[ASYNC_EVENT_INFO_SIGNATURE_LEN]; // Security signature
  96. HANDLE CompletionPort; // Completion port handle
  97. ULONG_PTR CompletionKey; // Completion key
  98. HWND hWindow; // Window handle
  99. UINT MessageStart; // Application's base window message
  100. BOOL bEventEx; // Flag that indicates to use FAX_EVENT_EX
  101. BOOL bLocalNotificationsOnly; // client registration for local events only
  102. handle_t hBinding; // RPC client binding handle
  103. BOOL bInUse; // Indicates that this ASYNC_EVENT_INFO was already processed in Fax_OpenConnection
  104. DWORD dwServerAPIVersion; // The API version of the server we're connected to (filtered)
  105. } ASYNC_EVENT_INFO, *PASYNC_EVENT_INFO;
  106. //
  107. // prototypes
  108. //
  109. VOID
  110. CloseFaxHandle(
  111. PHANDLE_ENTRY pHandleEntry
  112. );
  113. PHANDLE_ENTRY
  114. CreateNewServiceHandle(
  115. PFAX_HANDLE_DATA FaxData
  116. );
  117. PHANDLE_ENTRY
  118. CreateNewPortHandle(
  119. PFAX_HANDLE_DATA FaxData,
  120. DWORD Flags,
  121. HANDLE FaxPortHandle
  122. );
  123. PHANDLE_ENTRY
  124. CreateNewMsgEnumHandle(
  125. PFAX_HANDLE_DATA pFaxData
  126. );
  127. BOOL
  128. ConvertUnicodeStringInPlace(
  129. LPCWSTR UnicodeString
  130. );
  131. LPTSTR
  132. GetFaxPrinterName(
  133. HANDLE hFax
  134. );
  135. BOOL
  136. IsLocalFaxConnection(
  137. HANDLE FaxHandle
  138. );
  139. //
  140. // Fax Client RPC Client
  141. //
  142. DWORD
  143. FaxClientBindToFaxServer (
  144. IN LPCTSTR lpctstrServerName,
  145. IN LPCTSTR lpctstrServiceName,
  146. IN LPCTSTR lpctstrNetworkOptions,
  147. OUT RPC_BINDING_HANDLE * pBindingHandle
  148. );
  149. DWORD
  150. FaxClientUnbindFromFaxServer(
  151. IN RPC_BINDING_HANDLE BindingHandle
  152. );
  153. BOOL
  154. FaxClientInitRpcServer(
  155. VOID
  156. );
  157. VOID
  158. FaxClientTerminateRpcServer(
  159. VOID
  160. );
  161. //
  162. // Fax Client RPC Server
  163. //
  164. DWORD
  165. StartFaxClientRpcServer(
  166. VOID
  167. );
  168. DWORD
  169. StopFaxClientRpcServer(
  170. VOID
  171. );
  172. VOID
  173. DumpRPCExtendedStatus ();