2 * PROJECT: ReactOS Local Spooler
3 * LICENSE: GNU LGPL v2.1 or any later version as published by the Free Software Foundation
4 * PURPOSE: Precompiled Header for all source files
5 * COPYRIGHT: Copyright 2015 Colin Finck <colin@reactos.org>
11 #define WIN32_NO_STATUS
24 #include <ndk/rtlfuncs.h>
26 #define SKIPLIST_LEVELS 16
30 #include <wine/debug.h>
31 WINE_DEFAULT_DEBUG_CHANNEL(localspl
);
34 #define IS_VALID_JOB_ID(ID) (ID >= 1 && ID <= 99999)
35 #define IS_VALID_PRIORITY(P) (P >= MIN_PRIORITY && P <= MAX_PRIORITY)
38 #define MAX_PRINTER_NAME 220
39 #define SHD_WIN2003_SIGNATURE 0x4968
42 typedef BOOL (WINAPI
*PClosePrintProcessor
)(HANDLE
);
43 typedef BOOL (WINAPI
*PControlPrintProcessor
)(HANDLE
, DWORD
);
44 typedef BOOL (WINAPI
*PEnumPrintProcessorDatatypesW
)(LPWSTR
, LPWSTR
, DWORD
, LPBYTE
, DWORD
, LPDWORD
, LPDWORD
);
45 typedef DWORD (WINAPI
*PGetPrintProcessorCapabilities
)(LPWSTR
, DWORD
, LPBYTE
, DWORD
, LPDWORD
);
46 typedef HANDLE (WINAPI
*POpenPrintProcessor
)(LPWSTR
, PPRINTPROCESSOROPENDATA
);
47 typedef BOOL (WINAPI
*PPrintDocumentOnPrintProcessor
)(HANDLE
, LPWSTR
);
48 typedef LPMONITOREX(WINAPI
*PInitializePrintMonitor
)(PWSTR
);
49 typedef LPMONITOR2(WINAPI
*PInitializePrintMonitor2
)(PMONITORINIT
, PHANDLE
);
53 * Describes a Print Monitor.
55 typedef struct _LOCAL_PRINT_MONITOR
58 PWSTR pwszName
; /** Name of the Print Monitor as read from the registry. */
59 PWSTR pwszFileName
; /** DLL File Name of the Print Monitor. */
60 BOOL bIsLevel2
; /** Whether this Print Monitor supplies an InitializePrintMonitor2 API (preferred) instead of InitializePrintMonitor. */
61 PVOID pMonitor
; /** For bIsLevel2 == TRUE: LPMONITOR2 pointer returned by InitializePrintMonitor2.
62 For bIsLevel2 == FALSE: LPMONITOREX pointer returned by InitializePrintMonitor. */
63 HANDLE hMonitor
; /** Only used when bIsLevel2 == TRUE: Handle returned by InitializePrintMonitor2. */
65 LOCAL_PRINT_MONITOR
, *PLOCAL_PRINT_MONITOR
;
68 * Describes a Port handled by a Print Monitor.
70 typedef struct _LOCAL_PORT
73 PWSTR pwszName
; /** The name of the port (including the trailing colon). */
74 PLOCAL_PRINT_MONITOR pPrintMonitor
; /** The Print Monitor handling this port. */
76 LOCAL_PORT
, *PLOCAL_PORT
;
79 * Describes a Print Processor.
81 typedef struct _LOCAL_PRINT_PROCESSOR
85 PDATATYPES_INFO_1W pDatatypesInfo1
;
86 DWORD dwDatatypeCount
;
87 PClosePrintProcessor pfnClosePrintProcessor
;
88 PControlPrintProcessor pfnControlPrintProcessor
;
89 PEnumPrintProcessorDatatypesW pfnEnumPrintProcessorDatatypesW
;
90 PGetPrintProcessorCapabilities pfnGetPrintProcessorCapabilities
;
91 POpenPrintProcessor pfnOpenPrintProcessor
;
92 PPrintDocumentOnPrintProcessor pfnPrintDocumentOnPrintProcessor
;
94 LOCAL_PRINT_PROCESSOR
, *PLOCAL_PRINT_PROCESSOR
;
97 * Describes a printer and manages its print jobs.
98 * Created once for every printer at startup.
100 typedef struct _LOCAL_PRINTER
102 // This sort key must be the first element for LookupElementSkiplist to work!
103 PWSTR pwszPrinterName
;
107 PWSTR pwszPrinterDriver
;
108 PWSTR pwszDescription
;
109 PWSTR pwszDefaultDatatype
;
110 PDEVMODEW pDefaultDevMode
;
111 PLOCAL_PRINT_PROCESSOR pPrintProcessor
;
115 LOCAL_PRINTER
, *PLOCAL_PRINTER
;
118 * Describes an entire print job associated to a specific printer through the Printer member.
119 * Created with every valid call to LocalStartDocPrinter.
121 typedef struct _LOCAL_JOB
123 // This sort key must be the first element for LookupElementSkiplist to work!
124 DWORD dwJobID
; /** Internal and external ID of this Job */
126 BOOL bAddedJob
: 1; /** Whether AddJob has already been called on this Job. */
127 HANDLE hPrintProcessor
; /** Handle returned by OpenPrintProcessor while the Job is printing. */
128 PLOCAL_PRINTER pPrinter
; /** Associated Printer to this Job */
129 PLOCAL_PRINT_PROCESSOR pPrintProcessor
; /** Associated Print Processor to this Job */
130 DWORD dwPriority
; /** Priority of this Job from MIN_PRIORITY to MAX_PRIORITY, default being DEF_PRIORITY */
131 SYSTEMTIME stSubmitted
; /** Time of the submission of this Job */
132 PWSTR pwszUserName
; /** Optional; User that submitted the Job */
133 PWSTR pwszNotifyName
; /** Optional; User that shall be notified about the status of the Job */
134 PWSTR pwszDocumentName
; /** Optional; Name of the Document that is printed */
135 PWSTR pwszDatatype
; /** Datatype of the Document */
136 PWSTR pwszOutputFile
; /** Output File to spool the Job to */
137 PWSTR pwszPrintProcessorParameters
; /** Optional; Parameters for the chosen Print Processor */
138 PWSTR pwszStatus
; /** Optional; a Status Message for the Job */
139 DWORD dwTotalPages
; /** Total pages of the Document */
140 DWORD dwPagesPrinted
; /** Number of pages that have already been printed */
141 DWORD dwStartTime
; /** Earliest time in minutes since 12:00 AM UTC when this document can be printed */
142 DWORD dwUntilTime
; /** Latest time in minutes since 12:00 AM UTC when this document can be printed */
143 DWORD dwStatus
; /** JOB_STATUS_* flags of the Job */
144 PWSTR pwszMachineName
; /** Name of the machine that submitted the Job (prepended with two backslashes) */
145 PDEVMODEW pDevMode
; /** Associated Device Mode to this Job */
147 LOCAL_JOB
, *PLOCAL_JOB
;
150 * Describes a template for new print jobs for a specific printer.
151 * Created with every valid call to LocalOpenPrinter.
153 * This is needed, because you can supply defaults in a LocalOpenPrinter call, which affect all subsequent print jobs
154 * started with the same handle and a call to LocalStartDocPrinter.
156 typedef struct _LOCAL_PRINTER_HANDLE
158 BOOL bStartedDoc
: 1; /** Whether StartDocPrinter has already been called. */
159 HANDLE hSPLFile
; /** Handle to an opened SPL file for Printer Job handles. */
160 PLOCAL_PRINTER pPrinter
;
165 LOCAL_PRINTER_HANDLE
, *PLOCAL_PRINTER_HANDLE
;
168 * Describes a handle returned by LocalOpenPrinter.
169 * Suitable for all things that can be opened through LocalOpenPrinter.
171 typedef struct _LOCAL_HANDLE
179 PVOID pSpecificHandle
;
181 LOCAL_HANDLE
, *PLOCAL_HANDLE
;
184 * Describes the header of a print job serialized into a shadow file (.SHD)
185 * Documented in http://www.undocprint.org/formats/winspool/shd
186 * Compatible with Windows Server 2003
188 typedef struct _SHD_HEADER
198 DWORD offDocumentName
;
200 DWORD offPrinterName
;
203 DWORD offPrintProcessor
;
205 DWORD offPrintProcessorParameters
;
206 SYSTEMTIME stSubmitted
;
211 DWORD cbSecurityDescriptor
;
212 DWORD offSecurityDescriptor
;
216 DWORD offMachineName
;
219 SHD_HEADER
, *PSHD_HEADER
;
222 extern SKIPLIST GlobalJobList
;
223 DWORD WINAPI
CreateJob(PLOCAL_PRINTER_HANDLE pPrinterHandle
);
224 void FreeJob(PLOCAL_JOB pJob
);
225 DWORD
GetJobFilePath(PCWSTR pwszExtension
, DWORD dwJobID
, PWSTR pwszOutput
);
226 BOOL
InitializeGlobalJobList();
227 void InitializePrinterJobList(PLOCAL_PRINTER pPrinter
);
228 BOOL WINAPI
LocalAddJob(HANDLE hPrinter
, DWORD Level
, LPBYTE pData
, DWORD cbBuf
, LPDWORD pcbNeeded
);
229 BOOL WINAPI
LocalEnumJobs(HANDLE hPrinter
, DWORD FirstJob
, DWORD NoJobs
, DWORD Level
, PBYTE pStart
, DWORD cbBuf
, LPDWORD pcbNeeded
, LPDWORD pcReturned
);
230 BOOL WINAPI
LocalGetJob(HANDLE hPrinter
, DWORD JobId
, DWORD Level
, PBYTE pStart
, DWORD cbBuf
, LPDWORD pcbNeeded
);
231 BOOL WINAPI
LocalScheduleJob(HANDLE hPrinter
, DWORD dwJobID
);
232 BOOL WINAPI
LocalSetJob(HANDLE hPrinter
, DWORD JobId
, DWORD Level
, PBYTE pJobInfo
, DWORD Command
);
233 PLOCAL_JOB
ReadJobShadowFile(PCWSTR pwszFilePath
);
234 BOOL
WriteJobShadowFile(PWSTR pwszFilePath
, const PLOCAL_JOB pJob
);
237 extern const WCHAR wszCurrentEnvironment
[];
238 extern const DWORD cbCurrentEnvironment
;
239 extern const WCHAR wszDefaultDocumentName
[];
240 extern const WCHAR
* wszPrintProviderInfo
[3];
241 extern WCHAR wszSpoolDirectory
[MAX_PATH
];
242 extern DWORD cchSpoolDirectory
;
245 extern LIST_ENTRY PrintMonitorList
;
246 PLOCAL_PRINT_MONITOR
FindPrintMonitor(PCWSTR pwszName
);
247 BOOL
InitializePrintMonitorList();
248 BOOL WINAPI
LocalEnumMonitors(PWSTR pName
, DWORD Level
, PBYTE pMonitors
, DWORD cbBuf
, PDWORD pcbNeeded
, PDWORD pcReturned
);
251 PLOCAL_PORT
FindPort(PCWSTR pwszName
);
252 BOOL
InitializePortList();
253 BOOL WINAPI
LocalEnumPorts(PWSTR pName
, DWORD Level
, PBYTE pPorts
, DWORD cbBuf
, PDWORD pcbNeeded
, PDWORD pcReturned
);
256 extern SKIPLIST PrinterList
;
257 BOOL
InitializePrinterList();
258 BOOL WINAPI
LocalEnumPrinters(DWORD Flags
, LPWSTR Name
, DWORD Level
, LPBYTE pPrinterEnum
, DWORD cbBuf
, LPDWORD pcbNeeded
, LPDWORD pcReturned
);
259 BOOL WINAPI
LocalOpenPrinter(PWSTR lpPrinterName
, HANDLE
* phPrinter
, PPRINTER_DEFAULTSW pDefault
);
260 BOOL WINAPI
LocalReadPrinter(HANDLE hPrinter
, PVOID pBuf
, DWORD cbBuf
, PDWORD pNoBytesRead
);
261 DWORD WINAPI
LocalStartDocPrinter(HANDLE hPrinter
, DWORD Level
, LPBYTE pDocInfo
);
262 BOOL WINAPI
LocalStartPagePrinter(HANDLE hPrinter
);
263 BOOL WINAPI
LocalWritePrinter(HANDLE hPrinter
, LPVOID pBuf
, DWORD cbBuf
, LPDWORD pcWritten
);
264 BOOL WINAPI
LocalEndPagePrinter(HANDLE hPrinter
);
265 BOOL WINAPI
LocalEndDocPrinter(HANDLE hPrinter
);
266 BOOL WINAPI
LocalClosePrinter(HANDLE hPrinter
);
269 DWORD WINAPI
PrintingThreadProc(PLOCAL_JOB pJob
);
272 BOOL
FindDatatype(const PLOCAL_PRINT_PROCESSOR pPrintProcessor
, PCWSTR pwszDatatype
);
273 PLOCAL_PRINT_PROCESSOR
FindPrintProcessor(PCWSTR pwszName
);
274 BOOL
InitializePrintProcessorList();
275 BOOL WINAPI
LocalEnumPrintProcessorDatatypes(LPWSTR pName
, LPWSTR pPrintProcessorName
, DWORD Level
, LPBYTE pDatatypes
, DWORD cbBuf
, LPDWORD pcbNeeded
, LPDWORD pcReturned
);
276 BOOL WINAPI
LocalEnumPrintProcessors(LPWSTR pName
, LPWSTR pEnvironment
, DWORD Level
, LPBYTE pPrintProcessorInfo
, DWORD cbBuf
, LPDWORD pcbNeeded
, LPDWORD pcReturned
);
277 BOOL WINAPI
LocalGetPrintProcessorDirectory(LPWSTR pName
, LPWSTR pEnvironment
, DWORD Level
, LPBYTE pPrintProcessorInfo
, DWORD cbBuf
, LPDWORD pcbNeeded
);
280 PWSTR
AllocAndRegQueryWSZ(HKEY hKey
, PCWSTR pwszValueName
);
281 PDEVMODEW
DuplicateDevMode(PDEVMODEW pInput
);