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.

319 lines
6.3 KiB

  1. /*++
  2. Copyright (c) 1990-1994 Microsoft Corporation
  3. All rights reserved
  4. Module Name:
  5. Router.h
  6. Abstract:
  7. Holds defs for router
  8. Author:
  9. Albert Ting (AlbertT) 18-Jan-94
  10. Environment:
  11. User Mode -Win32
  12. Revision History:
  13. --*/
  14. #if SPOOLER_HEAP
  15. extern HANDLE ghMidlHeap;
  16. #endif
  17. typedef enum _ESTATUSCHANGE {
  18. STATUS_CHANGE_EMPTY = 0, // One of these is valid,
  19. STATUS_CHANGE_FORMING = 1, // but they still need x^2.
  20. STATUS_CHANGE_VALID = 2,
  21. STATUS_CHANGE_CLOSING = 0x000100, // bitfield
  22. STATUS_CHANGE_CLIENT = 0x000200, // Event valid (local pChange)
  23. STATUS_CHANGE_ACTIVE = 0x000400, // Currently processing or on LL
  24. STATUS_CHANGE_ACTIVE_REQ = 0x000800, // Needs to go on Linked List
  25. STATUS_CHANGE_INFO = 0x001000, // Info requested.
  26. STATUS_CHANGE_DISCARDED = 0x008000, // Discard locally
  27. STATUS_CHANGE_DISCARDNOTED = 0x010000, // Discard noted on client
  28. } ESTATUSCHANGE;
  29. typedef struct _LINK *PLINK, *LPLINK;
  30. typedef struct _LINK {
  31. PLINK pNext;
  32. } LINK;
  33. #if 1
  34. VOID
  35. LinkAdd(
  36. PLINK pLink,
  37. PLINK* ppLinkHead);
  38. #else
  39. #define LINKADDFAST
  40. #define LinkAdd(pLink, ppLinkHead) \
  41. { \
  42. (pLink)->pNext = *(ppLinkHead); \
  43. *(ppLinkHead) = (pLink); \
  44. }
  45. #endif
  46. VOID
  47. LinkDelete(
  48. PLINK pLink,
  49. PLINK* ppLinkHead);
  50. #define CLUSTERHANDLE_SIGNATURE 0x6262
  51. typedef struct _PRINTHANDLE *PPRINTHANDLE, *LPPRINTHANDLE;
  52. typedef struct _CHANGEINFO {
  53. LINK Link; // Must be first item
  54. PPRINTHANDLE pPrintHandle;
  55. DWORD fdwOptions;
  56. DWORD fdwFilterFlags; // Original filter of flags to watch
  57. DWORD fdwStatus; // Status from providor
  58. DWORD dwPollTime;
  59. DWORD dwPollTimeLeft;
  60. BOOL bResetPollTime;
  61. DWORD fdwFlags;
  62. PPRINTER_NOTIFY_INFO pPrinterNotifyInfo;
  63. } CHANGEINFO, *PCHANGEINFO;
  64. typedef struct _CHANGE {
  65. LINK Link; // Must be first item
  66. DWORD signature;
  67. ESTATUSCHANGE eStatus;
  68. DWORD dwColor;
  69. DWORD cRef;
  70. LPWSTR pszLocalMachine;
  71. CHANGEINFO ChangeInfo;
  72. DWORD dwCount; // number of notifications
  73. HANDLE hEvent; // Event for local notification
  74. DWORD fdwFlags;
  75. DWORD fdwChangeFlags; // Accumulated changes
  76. DWORD dwPrinterRemote; // Remote printer handle (ID only)
  77. HANDLE hNotifyRemote; // Remote notification handle
  78. } CHANGE, *PCHANGE, *LPCHANGE;
  79. #define CHANGEHANDLE_SIGNATURE 0x6368
  80. typedef struct _NOTIFY *PNOTIFY, *LPNOTIFY;
  81. #define NOTIFYHANDLE_SIGNATURE 0x6e6f
  82. typedef struct _PROVIDOR {
  83. struct _PROVIDOR *pNext;
  84. LPWSTR lpName;
  85. HANDLE hModule;
  86. FARPROC fpInitialize;
  87. PRINTPROVIDOR PrintProvidor;
  88. } PROVIDOR, *LPPROVIDOR;
  89. typedef struct _PRINTHANDLE {
  90. DWORD signature; // Must be first (match _NOTIFY)
  91. LPPROVIDOR pProvidor;
  92. HANDLE hPrinter;
  93. PCHANGE pChange;
  94. PNOTIFY pNotify;
  95. PPRINTHANDLE pNext; // List of handles waiting for replys
  96. DWORD fdwReplyTypes; // Types of replys being used.
  97. HANDLE hFileSpooler;
  98. LPWSTR szTempSpoolFile;
  99. LPWSTR pszPrinter;
  100. DWORD dwUniqueSessionID; // DWORD passed as a hprinter to remote machines
  101. // for notifications. Cant be 0 or 0xffffffff when in use.
  102. } PRINTHANDLE;
  103. #define PRINTHANDLE_SIGNATURE 0x6060
  104. typedef struct _GDIHANDLE {
  105. DWORD signature;
  106. LPPROVIDOR pProvidor;
  107. HANDLE hGdi;
  108. } GDIHANDLE, *PGDIHANDLE, *LPGDIHANDLE;
  109. #define GDIHANDLE_SIGNATURE 0x6161
  110. typedef struct _ROUTERCACHE {
  111. LPWSTR pPrinterName;
  112. BOOL bAvailable;
  113. LPPROVIDOR pProvidor;
  114. SYSTEMTIME st;
  115. } ROUTERCACHE, *PROUTERCACHE;
  116. #define ROUTERCACHE_DEFAULT_MAX 16
  117. LPPROVIDOR
  118. FindEntryinRouterCache(
  119. LPWSTR pPrinterName
  120. );
  121. DWORD
  122. AddEntrytoRouterCache(
  123. LPWSTR pPrinterName,
  124. LPPROVIDOR pProvidor
  125. );
  126. VOID
  127. DeleteEntryfromRouterCache(
  128. LPWSTR pPrinterName
  129. );
  130. DWORD
  131. RouterIsOlderThan(
  132. DWORD i,
  133. DWORD j
  134. );
  135. LPBYTE
  136. CopyPrinterNameToPrinterInfo4(
  137. LPWSTR pServerName,
  138. LPWSTR pPrinterName,
  139. LPBYTE pPrinter,
  140. LPBYTE pEnd);
  141. BOOL
  142. RouterOpenPrinterW(
  143. LPWSTR pPrinterName,
  144. HANDLE *pHandle,
  145. LPPRINTER_DEFAULTS pDefault,
  146. LPBYTE pSplClientInfo,
  147. DWORD dwLevel,
  148. BOOL bLocalPrintProvidor
  149. );
  150. VOID
  151. FixupOldProvidor(
  152. LPPRINTPROVIDOR pProvidor
  153. );
  154. extern BOOL Initialized;
  155. extern DWORD dwUpgradeFlag;
  156. extern CRITICAL_SECTION RouterNotifySection;
  157. extern LPWSTR pszSelfMachine;
  158. extern HANDLE hEventInit;
  159. extern LPPROVIDOR pLocalProvidor;
  160. extern LPWSTR szEnvironment;
  161. extern LPWSTR szLocalSplDll;
  162. extern WCHAR *szDevices;
  163. extern LPWSTR szPrintKey;
  164. extern LPWSTR szRegistryProvidors;
  165. extern LPWSTR szOrder;
  166. extern DWORD gbFailAllocs;
  167. extern WCHAR szMachineName[MAX_COMPUTERNAME_LENGTH+3];
  168. extern SERVICE_STATUS_HANDLE ghSplHandle;
  169. LPWSTR
  170. AppendOrderEntry(
  171. LPWSTR szOrderString,
  172. DWORD cbStringSize,
  173. LPWSTR szOrderEntry,
  174. LPDWORD pcbBytesReturned
  175. );
  176. LPWSTR
  177. RemoveOrderEntry(
  178. LPWSTR szOrderString,
  179. DWORD cbStringSize,
  180. LPWSTR szOrderEntry,
  181. LPDWORD pcbBytesReturned
  182. );
  183. BOOL
  184. WPCInit();
  185. VOID
  186. WPCDestroy();
  187. BOOL
  188. ThreadInit();
  189. VOID
  190. ThreadDestroy();
  191. VOID
  192. RundownPrinterChangeNotification(
  193. HANDLE hNotify);
  194. VOID
  195. FreePrinterHandle(
  196. PPRINTHANDLE pPrintHandle);
  197. BOOL
  198. FreeChange(
  199. PCHANGE pChange);
  200. VOID
  201. FreePrinterChangeInfo(
  202. PCHANGEINFO pChangeInfo);
  203. BOOL
  204. DeleteSubKeyTree(
  205. HKEY ParentHandle,
  206. WCHAR SubKeyName[]
  207. );
  208. BOOL
  209. ThreadNotify(
  210. LPPRINTHANDLE pPrintHandle);
  211. BOOL
  212. NotifyNeeded(
  213. PCHANGE pChange);
  214. VOID
  215. HandlePollNotifications();
  216. DWORD
  217. GetNetworkIdWorker(
  218. HKEY hKeyDevices,
  219. LPWSTR pDeviceName);
  220. VOID
  221. UpdateSignificantError(
  222. DWORD dwNewError,
  223. PDWORD pdwOldError
  224. );
  225. #if DBG
  226. VOID
  227. EnterRouterSem();
  228. VOID
  229. LeaveRouterSem();
  230. VOID
  231. RouterInSem();
  232. VOID
  233. RouterOutSem();
  234. #else
  235. #define EnterRouterSem() EnterCriticalSection(&RouterNotifySection)
  236. #define LeaveRouterSem() LeaveCriticalSection(&RouterNotifySection)
  237. #define RouterInSem()
  238. #define RouterOutSem()
  239. #endif