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