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