cb08315bbb374444758fa986b5bddb8291db84c2
[reactos.git] / reactos / win32ss / printing / providers / localspl / precomp.h
1 /*
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>
6 */
7
8 #ifndef _PRECOMP_H
9 #define _PRECOMP_H
10
11 #define WIN32_NO_STATUS
12 #include <limits.h>
13 #include <stdlib.h>
14 #include <wchar.h>
15
16 #include <windef.h>
17 #include <winbase.h>
18 #include <wingdi.h>
19 #include <winreg.h>
20 #include <winspool.h>
21 #include <winsplp.h>
22 #include <ndk/rtlfuncs.h>
23
24 #include <spoolss.h>
25
26 #include <wine/debug.h>
27 WINE_DEFAULT_DEBUG_CHANNEL(localspl);
28
29 // Macros
30 #define IS_VALID_JOB_ID(ID) (ID >= 1 && ID <= 99999)
31
32 // Constants
33 #define MAX_PRINTER_NAME 220
34 #define SHD_WIN2003_SIGNATURE 0x4968
35
36 // Function pointers
37 typedef BOOL (WINAPI *PClosePrintProcessor)(HANDLE);
38 typedef BOOL (WINAPI *PControlPrintProcessor)(HANDLE, DWORD);
39 typedef BOOL (WINAPI *PEnumPrintProcessorDatatypesW)(LPWSTR, LPWSTR, DWORD, LPBYTE, DWORD, LPDWORD, LPDWORD);
40 typedef DWORD (WINAPI *PGetPrintProcessorCapabilities)(LPWSTR, DWORD, LPBYTE, DWORD, LPDWORD);
41 typedef HANDLE (WINAPI *POpenPrintProcessor)(LPWSTR, PPRINTPROCESSOROPENDATA);
42 typedef BOOL (WINAPI *PPrintDocumentOnPrintProcessor)(HANDLE, LPWSTR);
43
44 // Structures
45 /**
46 * Describes a Print Processor.
47 */
48 typedef struct _LOCAL_PRINT_PROCESSOR
49 {
50 PWSTR pwszName;
51 RTL_GENERIC_TABLE DatatypeTable;
52 PClosePrintProcessor pfnClosePrintProcessor;
53 PControlPrintProcessor pfnControlPrintProcessor;
54 PEnumPrintProcessorDatatypesW pfnEnumPrintProcessorDatatypesW;
55 PGetPrintProcessorCapabilities pfnGetPrintProcessorCapabilities;
56 POpenPrintProcessor pfnOpenPrintProcessor;
57 PPrintDocumentOnPrintProcessor pfnPrintDocumentOnPrintProcessor;
58 }
59 LOCAL_PRINT_PROCESSOR, *PLOCAL_PRINT_PROCESSOR;
60
61 /**
62 * Describes a printer and manages its print jobs.
63 * Created once for every printer at startup.
64 */
65 typedef struct _LOCAL_PRINTER
66 {
67 PWSTR pwszPrinterName;
68 PWSTR pwszPrinterDriver;
69 PWSTR pwszDescription;
70 PWSTR pwszDefaultDatatype;
71 DEVMODEW DefaultDevMode;
72 PLOCAL_PRINT_PROCESSOR pPrintProcessor;
73 LIST_ENTRY JobQueue;
74 }
75 LOCAL_PRINTER, *PLOCAL_PRINTER;
76
77 /**
78 * Describes an entire print job associated to a specific printer through the Printer member.
79 * Created with every valid call to LocalStartDocPrinter.
80 */
81 typedef struct _LOCAL_JOB
82 {
83 LIST_ENTRY Entry;
84 PLOCAL_PRINTER Printer;
85 DWORD dwJobID;
86 PWSTR pwszDocumentName;
87 PWSTR pwszDatatype;
88 PWSTR pwszOutputFile;
89 DEVMODEW DevMode;
90 }
91 LOCAL_JOB, *PLOCAL_JOB;
92
93 /**
94 * Describes a template for new print jobs for a specific printer.
95 * Created with every valid call to LocalOpenPrinter.
96 *
97 * This is needed, because you can supply defaults in a LocalOpenPrinter call, which affect all subsequent print jobs
98 * started with the same handle and a call to LocalStartDocPrinter.
99 */
100 typedef struct _LOCAL_PRINTER_HANDLE
101 {
102 PLOCAL_PRINTER Printer;
103 PLOCAL_JOB StartedJob;
104 PWSTR pwszDatatype;
105 DEVMODEW DevMode;
106 }
107 LOCAL_PRINTER_HANDLE, *PLOCAL_PRINTER_HANDLE;
108
109 /**
110 * Describes a handle returned by LocalOpenPrinter.
111 * Suitable for all things that can be opened through LocalOpenPrinter.
112 */
113 typedef struct _LOCAL_HANDLE
114 {
115 enum { Printer, Monitor, Port } HandleType;
116 PVOID SpecificHandle;
117 }
118 LOCAL_HANDLE, *PLOCAL_HANDLE;
119
120 /**
121 * Describes the header of a print job serialized into a shadow file (.SHD)
122 * Documented in http://www.undocprint.org/formats/winspool/shd
123 * Compatible with Windows Server 2003
124 */
125 typedef struct _SHD_HEADER
126 {
127 DWORD dwSignature;
128 DWORD cbHeader;
129 WORD wStatus;
130 WORD wUnknown1;
131 DWORD dwJobID;
132 DWORD dwPriority;
133 DWORD offUserName;
134 DWORD offNotifyName;
135 DWORD offDocumentName;
136 DWORD offPort;
137 DWORD offPrinterName;
138 DWORD offDriverName;
139 DWORD offDevMode;
140 DWORD offPrintProcessor;
141 DWORD offDatatype;
142 DWORD dwUnknown2;
143 SYSTEMTIME stSubmitTime;
144 DWORD dwStartTime;
145 DWORD dwUntilTime;
146 DWORD dwUnknown6;
147 DWORD dwPageCount;
148 DWORD cbSecurityDescriptor;
149 DWORD offSecurityDescriptor;
150 DWORD dwUnknown3;
151 DWORD dwUnknown4;
152 DWORD dwUnknown5;
153 DWORD offComputerName;
154 DWORD dwSPLSize;
155 }
156 SHD_HEADER, *PSHD_HEADER;
157
158
159 // jobs.c
160 PLOCAL_JOB ReadJobShadowFile(PCWSTR pwszFilePath);
161 BOOL WriteJobShadowFile(PCWSTR pwszFilePath, const PLOCAL_JOB pJob);
162
163 // main.c
164 extern const WCHAR wszCurrentEnvironment[];
165 extern const WCHAR* wszPrintProviderInfo[3];
166 extern WCHAR wszSpoolDirectory[MAX_PATH];
167 extern DWORD cchSpoolDirectory;
168
169 // printers.c
170 extern RTL_GENERIC_TABLE PrinterTable;
171 void InitializePrinterTable();
172 BOOL WINAPI LocalEnumPrinters(DWORD Flags, LPWSTR Name, DWORD Level, LPBYTE pPrinterEnum, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned);
173 BOOL WINAPI LocalOpenPrinter(PWSTR lpPrinterName, HANDLE* phPrinter, PPRINTER_DEFAULTSW pDefault);
174 DWORD WINAPI LocalStartDocPrinter(HANDLE hPrinter, DWORD Level, LPBYTE pDocInfo);
175 BOOL WINAPI LocalStartPagePrinter(HANDLE hPrinter);
176 BOOL WINAPI LocalWritePrinter(HANDLE hPrinter, LPVOID pBuf, DWORD cbBuf, LPDWORD pcWritten);
177 BOOL WINAPI LocalEndPagePrinter(HANDLE hPrinter);
178 BOOL WINAPI LocalEndDocPrinter(HANDLE hPrinter);
179 BOOL WINAPI LocalClosePrinter(HANDLE hPrinter);
180
181 // printprocessors.c
182 extern RTL_GENERIC_TABLE PrintProcessorTable;
183 void InitializePrintProcessorTable();
184 BOOL WINAPI LocalEnumPrintProcessorDatatypes(LPWSTR pName, LPWSTR pPrintProcessorName, DWORD Level, LPBYTE pDatatypes, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned);
185 BOOL WINAPI LocalEnumPrintProcessors(LPWSTR pName, LPWSTR pEnvironment, DWORD Level, LPBYTE pPrintProcessorInfo, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned);
186 BOOL WINAPI LocalGetPrintProcessorDirectory(LPWSTR pName, LPWSTR pEnvironment, DWORD Level, LPBYTE pPrintProcessorInfo, DWORD cbBuf, LPDWORD pcbNeeded);
187
188 // tools.c
189 PWSTR AllocAndRegQueryWSZ(HKEY hKey, PCWSTR pwszValueName);
190 PVOID NTAPI GenericTableAllocateRoutine(PRTL_GENERIC_TABLE Table, CLONG ByteSize);
191 VOID NTAPI GenericTableFreeRoutine(PRTL_GENERIC_TABLE Table, PVOID Buffer);
192
193 #endif