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)
37 #define MAX_PRINTER_NAME 220
38 #define SHD_WIN2003_SIGNATURE 0x4968
41 typedef BOOL (WINAPI
*PClosePrintProcessor
)(HANDLE
);
42 typedef BOOL (WINAPI
*PControlPrintProcessor
)(HANDLE
, DWORD
);
43 typedef BOOL (WINAPI
*PEnumPrintProcessorDatatypesW
)(LPWSTR
, LPWSTR
, DWORD
, LPBYTE
, DWORD
, LPDWORD
, LPDWORD
);
44 typedef DWORD (WINAPI
*PGetPrintProcessorCapabilities
)(LPWSTR
, DWORD
, LPBYTE
, DWORD
, LPDWORD
);
45 typedef HANDLE (WINAPI
*POpenPrintProcessor
)(LPWSTR
, PPRINTPROCESSOROPENDATA
);
46 typedef BOOL (WINAPI
*PPrintDocumentOnPrintProcessor
)(HANDLE
, LPWSTR
);
50 * Describes a Print Processor.
52 typedef struct _LOCAL_PRINT_PROCESSOR
56 PDATATYPES_INFO_1W pDatatypesInfo1
;
57 DWORD dwDatatypeCount
;
58 PClosePrintProcessor pfnClosePrintProcessor
;
59 PControlPrintProcessor pfnControlPrintProcessor
;
60 PEnumPrintProcessorDatatypesW pfnEnumPrintProcessorDatatypesW
;
61 PGetPrintProcessorCapabilities pfnGetPrintProcessorCapabilities
;
62 POpenPrintProcessor pfnOpenPrintProcessor
;
63 PPrintDocumentOnPrintProcessor pfnPrintDocumentOnPrintProcessor
;
65 LOCAL_PRINT_PROCESSOR
, *PLOCAL_PRINT_PROCESSOR
;
68 * Describes a printer and manages its print jobs.
69 * Created once for every printer at startup.
71 typedef struct _LOCAL_PRINTER
73 // This sort key must be the first element for LookupElementSkiplist to work!
74 PWSTR pwszPrinterName
;
78 PWSTR pwszPrinterDriver
;
79 PWSTR pwszDescription
;
80 PWSTR pwszDefaultDatatype
;
81 DEVMODEW DefaultDevMode
;
82 PLOCAL_PRINT_PROCESSOR pPrintProcessor
;
85 LOCAL_PRINTER
, *PLOCAL_PRINTER
;
88 * Describes an entire print job associated to a specific printer through the Printer member.
89 * Created with every valid call to LocalStartDocPrinter.
91 typedef struct _LOCAL_JOB
93 // This sort key must be the first element for LookupElementSkiplist to work!
94 DWORD dwJobID
; // Internal and external ID of this Job
96 PLOCAL_PRINTER Printer
; // Associated Printer to this Job
97 DWORD dwPriority
; // Priority of this Job from MIN_PRIORITY to MAX_PRIORITY, default being DEF_PRIORITY
98 SYSTEMTIME stSubmitted
; // Time of the submission of this Job
99 PWSTR pwszUserName
; // User that submitted the Job
100 PWSTR pwszNotifyName
; // User that shall be notified about the status of the Job
101 PWSTR pwszDocumentName
; // Name of the Document that is printed
102 PWSTR pwszDatatype
; // Datatype of the Document
103 PWSTR pwszOutputFile
; // Output File to spool the Job to
104 DWORD dwTotalPages
; // Total pages of the Document
105 DWORD dwPagesPrinted
; // Number of pages that have already been printed
106 DWORD dwStartTime
; // Earliest time in minutes since 12:00 AM UTC when this document can be printed
107 DWORD dwUntilTime
; // Latest time in minutes since 12:00 AM UTC when this document can be printed
108 DWORD dwStatus
; // JOB_STATUS_* flags of the Job
109 PWSTR pwszMachineName
; // Name of the machine that submitted the Job (prepended with two backslashes)
110 DEVMODEW DevMode
; // Associated Device Mode to this Job
112 LOCAL_JOB
, *PLOCAL_JOB
;
115 * Describes a template for new print jobs for a specific printer.
116 * Created with every valid call to LocalOpenPrinter.
118 * This is needed, because you can supply defaults in a LocalOpenPrinter call, which affect all subsequent print jobs
119 * started with the same handle and a call to LocalStartDocPrinter.
121 typedef struct _LOCAL_PRINTER_HANDLE
123 PLOCAL_PRINTER Printer
;
124 PLOCAL_JOB StartedJob
;
128 LOCAL_PRINTER_HANDLE
, *PLOCAL_PRINTER_HANDLE
;
131 * Describes a handle returned by LocalOpenPrinter.
132 * Suitable for all things that can be opened through LocalOpenPrinter.
134 typedef struct _LOCAL_HANDLE
136 enum { Printer
, Monitor
, Port
} HandleType
;
137 PVOID SpecificHandle
;
139 LOCAL_HANDLE
, *PLOCAL_HANDLE
;
142 * Describes the header of a print job serialized into a shadow file (.SHD)
143 * Documented in http://www.undocprint.org/formats/winspool/shd
144 * Compatible with Windows Server 2003
146 typedef struct _SHD_HEADER
156 DWORD offDocumentName
;
158 DWORD offPrinterName
;
161 DWORD offPrintProcessor
;
164 SYSTEMTIME stSubmitted
;
169 DWORD cbSecurityDescriptor
;
170 DWORD offSecurityDescriptor
;
174 DWORD offMachineName
;
177 SHD_HEADER
, *PSHD_HEADER
;
181 extern SKIPLIST GlobalJobList
;
182 BOOL
GetNextJobID(PDWORD dwJobID
);
183 void InitializeGlobalJobList();
184 void InitializePrinterJobList(PLOCAL_PRINTER pPrinter
);
185 BOOL WINAPI
LocalAddJob(HANDLE hPrinter
, DWORD Level
, LPBYTE pData
, DWORD cbBuf
, LPDWORD pcbNeeded
);
186 BOOL WINAPI
LocalGetJob(HANDLE hPrinter
, DWORD JobId
, DWORD Level
, LPBYTE pOutput
, DWORD cbBuf
, LPDWORD pcbNeeded
);
187 PLOCAL_JOB
ReadJobShadowFile(PCWSTR pwszFilePath
);
188 BOOL
WriteJobShadowFile(PCWSTR pwszFilePath
, const PLOCAL_JOB pJob
);
191 extern const WCHAR wszCurrentEnvironment
[];
192 extern const WCHAR wszDefaultDocumentName
[];
193 extern const WCHAR
* wszPrintProviderInfo
[3];
194 extern WCHAR wszSpoolDirectory
[MAX_PATH
];
195 extern DWORD cchSpoolDirectory
;
198 extern SKIPLIST PrinterList
;
199 void InitializePrinterList();
200 BOOL WINAPI
LocalEnumPrinters(DWORD Flags
, LPWSTR Name
, DWORD Level
, LPBYTE pPrinterEnum
, DWORD cbBuf
, LPDWORD pcbNeeded
, LPDWORD pcReturned
);
201 BOOL WINAPI
LocalOpenPrinter(PWSTR lpPrinterName
, HANDLE
* phPrinter
, PPRINTER_DEFAULTSW pDefault
);
202 DWORD WINAPI
LocalStartDocPrinter(HANDLE hPrinter
, DWORD Level
, LPBYTE pDocInfo
);
203 BOOL WINAPI
LocalStartPagePrinter(HANDLE hPrinter
);
204 BOOL WINAPI
LocalWritePrinter(HANDLE hPrinter
, LPVOID pBuf
, DWORD cbBuf
, LPDWORD pcWritten
);
205 BOOL WINAPI
LocalEndPagePrinter(HANDLE hPrinter
);
206 BOOL WINAPI
LocalEndDocPrinter(HANDLE hPrinter
);
207 BOOL WINAPI
LocalClosePrinter(HANDLE hPrinter
);
210 BOOL
FindDatatype(PLOCAL_PRINT_PROCESSOR pPrintProcessor
, PWSTR pwszDatatype
);
211 PLOCAL_PRINT_PROCESSOR
FindPrintProcessor(PWSTR pwszName
);
212 void InitializePrintProcessorList();
213 BOOL WINAPI
LocalEnumPrintProcessorDatatypes(LPWSTR pName
, LPWSTR pPrintProcessorName
, DWORD Level
, LPBYTE pDatatypes
, DWORD cbBuf
, LPDWORD pcbNeeded
, LPDWORD pcReturned
);
214 BOOL WINAPI
LocalEnumPrintProcessors(LPWSTR pName
, LPWSTR pEnvironment
, DWORD Level
, LPBYTE pPrintProcessorInfo
, DWORD cbBuf
, LPDWORD pcbNeeded
, LPDWORD pcReturned
);
215 BOOL WINAPI
LocalGetPrintProcessorDirectory(LPWSTR pName
, LPWSTR pEnvironment
, DWORD Level
, LPBYTE pPrintProcessorInfo
, DWORD cbBuf
, LPDWORD pcbNeeded
);
218 PWSTR
AllocAndRegQueryWSZ(HKEY hKey
, PCWSTR pwszValueName
);