[LOCALSPL]
[reactos.git] / reactos / win32ss / printing / providers / localspl / main.c
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: Main functions
5 * COPYRIGHT: Copyright 2015 Colin Finck <colin@reactos.org>
6 */
7
8 #include "precomp.h"
9
10 // Global Variables
11 WCHAR wszSpoolDirectory[MAX_PATH];
12 DWORD cchSpoolDirectory;
13
14 // Global Constants
15 const WCHAR wszCurrentEnvironment[] =
16 #if defined(_X86_)
17 L"Windows NT x86";
18 #elif defined(_AMD64_)
19 L"Windows x64";
20 #elif defined(_ARM_)
21 L"Windows ARM";
22 #else
23 #error Unsupported architecture
24 #endif
25
26 const DWORD cbCurrentEnvironment = sizeof(wszCurrentEnvironment);
27
28 const WCHAR wszDefaultDocumentName[] = L"Local Downlevel Document";
29
30 const WCHAR* wszPrintProviderInfo[3] = {
31 L"Windows NT Local Print Providor", // Name
32 L"Windows NT Local Printers", // Description
33 L"Locally connected Printers" // Comment
34 };
35
36 // Local Constants
37 static const PRINTPROVIDOR _PrintProviderFunctions = {
38 LocalOpenPrinter, // fpOpenPrinter
39 LocalSetJob, // fpSetJob
40 LocalGetJob, // fpGetJob
41 LocalEnumJobs, // fpEnumJobs
42 NULL, // fpAddPrinter
43 NULL, // fpDeletePrinter
44 NULL, // fpSetPrinter
45 NULL, // fpGetPrinter
46 LocalEnumPrinters, // fpEnumPrinters
47 NULL, // fpAddPrinterDriver
48 NULL, // fpEnumPrinterDrivers
49 NULL, // fpGetPrinterDriver
50 NULL, // fpGetPrinterDriverDirectory
51 NULL, // fpDeletePrinterDriver
52 NULL, // fpAddPrintProcessor
53 LocalEnumPrintProcessors, // fpEnumPrintProcessors
54 LocalGetPrintProcessorDirectory, // fpGetPrintProcessorDirectory
55 NULL, // fpDeletePrintProcessor
56 LocalEnumPrintProcessorDatatypes, // fpEnumPrintProcessorDatatypes
57 LocalStartDocPrinter, // fpStartDocPrinter
58 LocalStartPagePrinter, // fpStartPagePrinter
59 LocalWritePrinter, // fpWritePrinter
60 LocalEndPagePrinter, // fpEndPagePrinter
61 NULL, // fpAbortPrinter
62 NULL, // fpReadPrinter
63 LocalEndDocPrinter, // fpEndDocPrinter
64 LocalAddJob, // fpAddJob
65 LocalScheduleJob, // fpScheduleJob
66 NULL, // fpGetPrinterData
67 NULL, // fpSetPrinterData
68 NULL, // fpWaitForPrinterChange
69 LocalClosePrinter, // fpClosePrinter
70 NULL, // fpAddForm
71 NULL, // fpDeleteForm
72 NULL, // fpGetForm
73 NULL, // fpSetForm
74 NULL, // fpEnumForms
75 LocalEnumMonitors, // fpEnumMonitors
76 LocalEnumPorts, // fpEnumPorts
77 NULL, // fpAddPort
78 NULL, // fpConfigurePort
79 NULL, // fpDeletePort
80 NULL, // fpCreatePrinterIC
81 NULL, // fpPlayGdiScriptOnPrinterIC
82 NULL, // fpDeletePrinterIC
83 NULL, // fpAddPrinterConnection
84 NULL, // fpDeletePrinterConnection
85 NULL, // fpPrinterMessageBox
86 NULL, // fpAddMonitor
87 NULL, // fpDeleteMonitor
88 NULL, // fpResetPrinter
89 NULL, // fpGetPrinterDriverEx
90 NULL, // fpFindFirstPrinterChangeNotification
91 NULL, // fpFindClosePrinterChangeNotification
92 NULL, // fpAddPortEx
93 NULL, // fpShutDown
94 NULL, // fpRefreshPrinterChangeNotification
95 NULL, // fpOpenPrinterEx
96 NULL, // fpAddPrinterEx
97 NULL, // fpSetPort
98 NULL, // fpEnumPrinterData
99 NULL, // fpDeletePrinterData
100 NULL, // fpClusterSplOpen
101 NULL, // fpClusterSplClose
102 NULL, // fpClusterSplIsAlive
103 NULL, // fpSetPrinterDataEx
104 NULL, // fpGetPrinterDataEx
105 NULL, // fpEnumPrinterDataEx
106 NULL, // fpEnumPrinterKey
107 NULL, // fpDeletePrinterDataEx
108 NULL, // fpDeletePrinterKey
109 NULL, // fpSeekPrinter
110 NULL, // fpDeletePrinterDriverEx
111 NULL, // fpAddPerMachineConnection
112 NULL, // fpDeletePerMachineConnection
113 NULL, // fpEnumPerMachineConnections
114 NULL, // fpXcvData
115 NULL, // fpAddPrinterDriverEx
116 NULL, // fpSplReadPrinter
117 NULL, // fpDriverUnloadComplete
118 NULL, // fpGetSpoolFileInfo
119 NULL, // fpCommitSpoolData
120 NULL, // fpCloseSpoolFileHandle
121 NULL, // fpFlushPrinter
122 NULL, // fpSendRecvBidiData
123 NULL, // fpAddDriverCatalog
124 };
125
126 static void
127 _GetSpoolDirectory()
128 {
129 const WCHAR wszSpoolPath[] = L"\\spool";
130 const DWORD cchSpoolPath = _countof(wszSpoolPath) - 1;
131
132 // Get the system directory and append the "spool" subdirectory.
133 // Forget about length checks here. If this doesn't fit into MAX_PATH, our OS has more serious problems...
134 cchSpoolDirectory = GetSystemDirectoryW(wszSpoolDirectory, MAX_PATH);
135 CopyMemory(&wszSpoolDirectory[cchSpoolDirectory], wszSpoolPath, (cchSpoolPath + 1) * sizeof(WCHAR));
136 cchSpoolDirectory += cchSpoolPath;
137 }
138
139 BOOL WINAPI
140 DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
141 {
142 switch (fdwReason)
143 {
144 case DLL_PROCESS_ATTACH:
145 DisableThreadLibraryCalls(hinstDLL);
146 _GetSpoolDirectory();
147
148 return InitializePrintMonitorList() &&
149 InitializePortList() &&
150 InitializePrintProcessorList() &&
151 InitializePrinterList() &&
152 InitializeGlobalJobList();
153
154 default:
155 return TRUE;
156 }
157 }
158
159 BOOL WINAPI
160 InitializePrintProvidor(LPPRINTPROVIDOR pPrintProvidor, DWORD cbPrintProvidor, LPWSTR pFullRegistryPath)
161 {
162 CopyMemory(pPrintProvidor, &_PrintProviderFunctions, min(cbPrintProvidor, sizeof(PRINTPROVIDOR)));
163
164 SetLastError(ERROR_SUCCESS);
165 return TRUE;
166 }