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
;
76 PWSTR pwszPrinterDriver
;
77 PWSTR pwszDescription
;
78 PWSTR pwszDefaultDatatype
;
79 DEVMODEW DefaultDevMode
;
80 PLOCAL_PRINT_PROCESSOR pPrintProcessor
;
83 LOCAL_PRINTER
, *PLOCAL_PRINTER
;
86 * Describes an entire print job associated to a specific printer through the Printer member.
87 * Created with every valid call to LocalStartDocPrinter.
89 typedef struct _LOCAL_JOB
91 // This sort key must be the first element for LookupElementSkiplist to work!
92 DWORD dwJobID
; // Internal and external ID of this Job
94 PLOCAL_PRINTER Printer
; // Associated Printer to this Job
95 DWORD dwPriority
; // Priority of this Job from MIN_PRIORITY to MAX_PRIORITY, default being DEF_PRIORITY
96 SYSTEMTIME stSubmitted
; // Time of the submission of this Job
97 PWSTR pwszUserName
; // User that submitted the Job
98 PWSTR pwszNotifyName
; // User that shall be notified about the status of the Job
99 PWSTR pwszDocumentName
; // Name of the Document that is printed
100 PWSTR pwszDatatype
; // Datatype of the Document
101 PWSTR pwszOutputFile
; // Output File to spool the Job to
102 DWORD dwTotalPages
; // Total pages of the Document
103 DWORD dwPagesPrinted
; // Number of pages that have already been printed
104 DWORD dwStartTime
; // Earliest time in minutes since 12:00 AM UTC when this document can be printed
105 DWORD dwUntilTime
; // Latest time in minutes since 12:00 AM UTC when this document can be printed
106 DWORD dwStatus
; // JOB_STATUS_* flags of the Job
107 PWSTR pwszMachineName
; // Name of the machine that submitted the Job (prepended with two backslashes)
108 DEVMODEW DevMode
; // Associated Device Mode to this Job
110 LOCAL_JOB
, *PLOCAL_JOB
;
113 * Describes a template for new print jobs for a specific printer.
114 * Created with every valid call to LocalOpenPrinter.
116 * This is needed, because you can supply defaults in a LocalOpenPrinter call, which affect all subsequent print jobs
117 * started with the same handle and a call to LocalStartDocPrinter.
119 typedef struct _LOCAL_PRINTER_HANDLE
121 PLOCAL_PRINTER Printer
;
122 PLOCAL_JOB StartedJob
;
126 LOCAL_PRINTER_HANDLE
, *PLOCAL_PRINTER_HANDLE
;
129 * Describes a handle returned by LocalOpenPrinter.
130 * Suitable for all things that can be opened through LocalOpenPrinter.
132 typedef struct _LOCAL_HANDLE
134 enum { Printer
, Monitor
, Port
} HandleType
;
135 PVOID SpecificHandle
;
137 LOCAL_HANDLE
, *PLOCAL_HANDLE
;
140 * Describes the header of a print job serialized into a shadow file (.SHD)
141 * Documented in http://www.undocprint.org/formats/winspool/shd
142 * Compatible with Windows Server 2003
144 typedef struct _SHD_HEADER
154 DWORD offDocumentName
;
156 DWORD offPrinterName
;
159 DWORD offPrintProcessor
;
162 SYSTEMTIME stSubmitted
;
167 DWORD cbSecurityDescriptor
;
168 DWORD offSecurityDescriptor
;
172 DWORD offMachineName
;
175 SHD_HEADER
, *PSHD_HEADER
;
179 extern SKIPLIST GlobalJobList
;
180 BOOL
GetNextJobID(PDWORD dwJobID
);
181 void InitializeGlobalJobList();
182 void InitializePrinterJobList(PLOCAL_PRINTER pPrinter
);
183 BOOL WINAPI
LocalAddJob(HANDLE hPrinter
, DWORD Level
, LPBYTE pData
, DWORD cbBuf
, LPDWORD pcbNeeded
);
184 BOOL WINAPI
LocalGetJob(HANDLE hPrinter
, DWORD JobId
, DWORD Level
, LPBYTE pOutput
, DWORD cbBuf
, LPDWORD pcbNeeded
);
185 PLOCAL_JOB
ReadJobShadowFile(PCWSTR pwszFilePath
);
186 BOOL
WriteJobShadowFile(PCWSTR pwszFilePath
, const PLOCAL_JOB pJob
);
189 extern const WCHAR wszCurrentEnvironment
[];
190 extern const WCHAR wszDefaultDocumentName
[];
191 extern const WCHAR
* wszPrintProviderInfo
[3];
192 extern WCHAR wszSpoolDirectory
[MAX_PATH
];
193 extern DWORD cchSpoolDirectory
;
196 extern SKIPLIST PrinterList
;
197 void InitializePrinterList();
198 BOOL WINAPI
LocalEnumPrinters(DWORD Flags
, LPWSTR Name
, DWORD Level
, LPBYTE pPrinterEnum
, DWORD cbBuf
, LPDWORD pcbNeeded
, LPDWORD pcReturned
);
199 BOOL WINAPI
LocalOpenPrinter(PWSTR lpPrinterName
, HANDLE
* phPrinter
, PPRINTER_DEFAULTSW pDefault
);
200 DWORD WINAPI
LocalStartDocPrinter(HANDLE hPrinter
, DWORD Level
, LPBYTE pDocInfo
);
201 BOOL WINAPI
LocalStartPagePrinter(HANDLE hPrinter
);
202 BOOL WINAPI
LocalWritePrinter(HANDLE hPrinter
, LPVOID pBuf
, DWORD cbBuf
, LPDWORD pcWritten
);
203 BOOL WINAPI
LocalEndPagePrinter(HANDLE hPrinter
);
204 BOOL WINAPI
LocalEndDocPrinter(HANDLE hPrinter
);
205 BOOL WINAPI
LocalClosePrinter(HANDLE hPrinter
);
208 BOOL
FindDatatype(PLOCAL_PRINT_PROCESSOR pPrintProcessor
, PWSTR pwszDatatype
);
209 PLOCAL_PRINT_PROCESSOR
FindPrintProcessor(PWSTR pwszName
);
210 void InitializePrintProcessorList();
211 BOOL WINAPI
LocalEnumPrintProcessorDatatypes(LPWSTR pName
, LPWSTR pPrintProcessorName
, DWORD Level
, LPBYTE pDatatypes
, DWORD cbBuf
, LPDWORD pcbNeeded
, LPDWORD pcReturned
);
212 BOOL WINAPI
LocalEnumPrintProcessors(LPWSTR pName
, LPWSTR pEnvironment
, DWORD Level
, LPBYTE pPrintProcessorInfo
, DWORD cbBuf
, LPDWORD pcbNeeded
, LPDWORD pcReturned
);
213 BOOL WINAPI
LocalGetPrintProcessorDirectory(LPWSTR pName
, LPWSTR pEnvironment
, DWORD Level
, LPBYTE pPrintProcessorInfo
, DWORD cbBuf
, LPDWORD pcbNeeded
);
216 PWSTR
AllocAndRegQueryWSZ(HKEY hKey
, PCWSTR pwszValueName
);