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