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
);
51 * Describes a Print Processor.
53 typedef struct _LOCAL_PRINT_PROCESSOR
57 PDATATYPES_INFO_1W pDatatypesInfo1
;
58 DWORD dwDatatypeCount
;
59 PClosePrintProcessor pfnClosePrintProcessor
;
60 PControlPrintProcessor pfnControlPrintProcessor
;
61 PEnumPrintProcessorDatatypesW pfnEnumPrintProcessorDatatypesW
;
62 PGetPrintProcessorCapabilities pfnGetPrintProcessorCapabilities
;
63 POpenPrintProcessor pfnOpenPrintProcessor
;
64 PPrintDocumentOnPrintProcessor pfnPrintDocumentOnPrintProcessor
;
66 LOCAL_PRINT_PROCESSOR
, *PLOCAL_PRINT_PROCESSOR
;
69 * Describes a printer and manages its print jobs.
70 * Created once for every printer at startup.
72 typedef struct _LOCAL_PRINTER
74 // This sort key must be the first element for LookupElementSkiplist to work!
75 PWSTR pwszPrinterName
;
79 PWSTR pwszPrinterDriver
;
80 PWSTR pwszDescription
;
81 PWSTR pwszDefaultDatatype
;
82 DEVMODEW DefaultDevMode
;
83 PLOCAL_PRINT_PROCESSOR pPrintProcessor
;
86 LOCAL_PRINTER
, *PLOCAL_PRINTER
;
89 * Describes an entire print job associated to a specific printer through the Printer member.
90 * Created with every valid call to LocalStartDocPrinter.
92 typedef struct _LOCAL_JOB
94 // This sort key must be the first element for LookupElementSkiplist to work!
95 DWORD dwJobID
; // Internal and external ID of this Job
97 PLOCAL_PRINTER pPrinter
; // Associated Printer to this Job
98 PLOCAL_PRINT_PROCESSOR pPrintProcessor
; // Associated Print Processor to this Job
99 DWORD dwPriority
; // Priority of this Job from MIN_PRIORITY to MAX_PRIORITY, default being DEF_PRIORITY
100 SYSTEMTIME stSubmitted
; // Time of the submission of this Job
101 PWSTR pwszUserName
; // User that submitted the Job
102 PWSTR pwszNotifyName
; // User that shall be notified about the status of the Job
103 PWSTR pwszDocumentName
; // Name of the Document that is printed
104 PWSTR pwszDatatype
; // Datatype of the Document
105 PWSTR pwszOutputFile
; // Output File to spool the Job to
106 PWSTR pwszPrintProcessorParameters
; // Optional; Parameters for the chosen Print Processor
107 PWSTR pwszStatus
; // Optional; a Status Message for the Job
108 DWORD dwTotalPages
; // Total pages of the Document
109 DWORD dwPagesPrinted
; // Number of pages that have already been printed
110 DWORD dwStartTime
; // Earliest time in minutes since 12:00 AM UTC when this document can be printed
111 DWORD dwUntilTime
; // Latest time in minutes since 12:00 AM UTC when this document can be printed
112 DWORD dwStatus
; // JOB_STATUS_* flags of the Job
113 PWSTR pwszMachineName
; // Name of the machine that submitted the Job (prepended with two backslashes)
114 DEVMODEW DevMode
; // Associated Device Mode to this Job
116 LOCAL_JOB
, *PLOCAL_JOB
;
119 * Describes a template for new print jobs for a specific printer.
120 * Created with every valid call to LocalOpenPrinter.
122 * This is needed, because you can supply defaults in a LocalOpenPrinter call, which affect all subsequent print jobs
123 * started with the same handle and a call to LocalStartDocPrinter.
125 typedef struct _LOCAL_PRINTER_HANDLE
127 PLOCAL_PRINTER pPrinter
;
128 PLOCAL_JOB pStartedJob
;
132 LOCAL_PRINTER_HANDLE
, *PLOCAL_PRINTER_HANDLE
;
135 * Describes a handle returned by LocalOpenPrinter.
136 * Suitable for all things that can be opened through LocalOpenPrinter.
138 typedef struct _LOCAL_HANDLE
140 enum { Printer
, Monitor
, Port
} HandleType
;
141 PVOID pSpecificHandle
;
143 LOCAL_HANDLE
, *PLOCAL_HANDLE
;
146 * Describes the header of a print job serialized into a shadow file (.SHD)
147 * Documented in http://www.undocprint.org/formats/winspool/shd
148 * Compatible with Windows Server 2003
150 typedef struct _SHD_HEADER
160 DWORD offDocumentName
;
162 DWORD offPrinterName
;
165 DWORD offPrintProcessor
;
168 SYSTEMTIME stSubmitted
;
173 DWORD cbSecurityDescriptor
;
174 DWORD offSecurityDescriptor
;
178 DWORD offMachineName
;
181 SHD_HEADER
, *PSHD_HEADER
;
185 extern SKIPLIST GlobalJobList
;
186 BOOL
GetNextJobID(PDWORD dwJobID
);
187 void InitializeGlobalJobList();
188 void InitializePrinterJobList(PLOCAL_PRINTER pPrinter
);
189 BOOL WINAPI
LocalAddJob(HANDLE hPrinter
, DWORD Level
, LPBYTE pData
, DWORD cbBuf
, LPDWORD pcbNeeded
);
190 BOOL WINAPI
LocalGetJob(HANDLE hPrinter
, DWORD JobId
, DWORD Level
, LPBYTE pOutput
, DWORD cbBuf
, LPDWORD pcbNeeded
);
191 BOOL WINAPI
LocalSetJob(HANDLE hPrinter
, DWORD JobId
, DWORD Level
, PBYTE pJobInfo
, DWORD Command
);
192 PLOCAL_JOB
ReadJobShadowFile(PCWSTR pwszFilePath
);
193 BOOL
WriteJobShadowFile(PCWSTR pwszFilePath
, const PLOCAL_JOB pJob
);
196 extern const WCHAR wszCurrentEnvironment
[];
197 extern const WCHAR wszDefaultDocumentName
[];
198 extern const WCHAR
* wszPrintProviderInfo
[3];
199 extern WCHAR wszSpoolDirectory
[MAX_PATH
];
200 extern DWORD cchSpoolDirectory
;
203 extern SKIPLIST PrinterList
;
204 void InitializePrinterList();
205 BOOL WINAPI
LocalEnumPrinters(DWORD Flags
, LPWSTR Name
, DWORD Level
, LPBYTE pPrinterEnum
, DWORD cbBuf
, LPDWORD pcbNeeded
, LPDWORD pcReturned
);
206 BOOL WINAPI
LocalOpenPrinter(PWSTR lpPrinterName
, HANDLE
* phPrinter
, PPRINTER_DEFAULTSW pDefault
);
207 DWORD WINAPI
LocalStartDocPrinter(HANDLE hPrinter
, DWORD Level
, LPBYTE pDocInfo
);
208 BOOL WINAPI
LocalStartPagePrinter(HANDLE hPrinter
);
209 BOOL WINAPI
LocalWritePrinter(HANDLE hPrinter
, LPVOID pBuf
, DWORD cbBuf
, LPDWORD pcWritten
);
210 BOOL WINAPI
LocalEndPagePrinter(HANDLE hPrinter
);
211 BOOL WINAPI
LocalEndDocPrinter(HANDLE hPrinter
);
212 BOOL WINAPI
LocalClosePrinter(HANDLE hPrinter
);
215 BOOL
FindDatatype(PLOCAL_PRINT_PROCESSOR pPrintProcessor
, PWSTR pwszDatatype
);
216 PLOCAL_PRINT_PROCESSOR
FindPrintProcessor(PWSTR pwszName
);
217 void InitializePrintProcessorList();
218 BOOL WINAPI
LocalEnumPrintProcessorDatatypes(LPWSTR pName
, LPWSTR pPrintProcessorName
, DWORD Level
, LPBYTE pDatatypes
, DWORD cbBuf
, LPDWORD pcbNeeded
, LPDWORD pcReturned
);
219 BOOL WINAPI
LocalEnumPrintProcessors(LPWSTR pName
, LPWSTR pEnvironment
, DWORD Level
, LPBYTE pPrintProcessorInfo
, DWORD cbBuf
, LPDWORD pcbNeeded
, LPDWORD pcReturned
);
220 BOOL WINAPI
LocalGetPrintProcessorDirectory(LPWSTR pName
, LPWSTR pEnvironment
, DWORD Level
, LPBYTE pPrintProcessorInfo
, DWORD cbBuf
, LPDWORD pcbNeeded
);
223 PWSTR
AllocAndRegQueryWSZ(HKEY hKey
, PCWSTR pwszValueName
);