bc9963b4f211d2be4b1227eff7d25ec03735c5ab
[reactos.git] / reactos / win32ss / printing / base / spoolss / main.c
1 /*
2 * PROJECT: ReactOS Spooler Router
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 HANDLE hProcessHeap;
11 PRINTPROVIDOR LocalSplFuncs;
12
13
14 BOOL WINAPI
15 DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
16 {
17 switch (fdwReason)
18 {
19 case DLL_PROCESS_ATTACH:
20 DisableThreadLibraryCalls(hinstDLL);
21 hProcessHeap = GetProcessHeap();
22 break;
23 }
24
25 return TRUE;
26 }
27
28 BOOL WINAPI
29 InitializeRouter(HANDLE SpoolerStatusHandle)
30 {
31 HINSTANCE hinstLocalSpl;
32 PInitializePrintProvidor pfnInitializePrintProvidor;
33
34 // Only initialize localspl.dll for now.
35 // This function should later look for all available print providers in the registry and initialize all of them.
36 hinstLocalSpl = LoadLibraryW(L"localspl");
37 if (!hinstLocalSpl)
38 {
39 ERR("LoadLibraryW for localspl failed with error %lu!\n", GetLastError());
40 return FALSE;
41 }
42
43 pfnInitializePrintProvidor = (PInitializePrintProvidor)GetProcAddress(hinstLocalSpl, "InitializePrintProvidor");
44 if (!pfnInitializePrintProvidor)
45 {
46 ERR("GetProcAddress failed with error %lu!\n", GetLastError());
47 return FALSE;
48 }
49
50 if (!pfnInitializePrintProvidor(&LocalSplFuncs, sizeof(PRINTPROVIDOR), NULL))
51 {
52 ERR("InitializePrintProvidor failed for localspl with error %lu!\n", GetLastError());
53 return FALSE;
54 }
55
56 return TRUE;
57 }
58
59 BOOL WINAPI
60 SplInitializeWinSpoolDrv(PVOID* pTable)
61 {
62 HINSTANCE hWinspool;
63 int i;
64
65 hWinspool = LoadLibraryW(L"winspool.drv");
66 if (!hWinspool)
67 {
68 ERR("Could not load winspool.drv, last error is %lu!\n", GetLastError());
69 return FALSE;
70 }
71
72 // Get the function pointers which are meant to be returned by this function.
73 pTable[0] = GetProcAddress(hWinspool, "OpenPrinterW");
74 pTable[1] = GetProcAddress(hWinspool, "ClosePrinter");
75 pTable[2] = GetProcAddress(hWinspool, "SpoolerDevQueryPrintW");
76 pTable[3] = GetProcAddress(hWinspool, "SpoolerPrinterEvent");
77 pTable[4] = GetProcAddress(hWinspool, "DocumentPropertiesW");
78 pTable[5] = GetProcAddress(hWinspool, (LPSTR)212);
79 pTable[6] = GetProcAddress(hWinspool, (LPSTR)213);
80 pTable[7] = GetProcAddress(hWinspool, (LPSTR)214);
81 pTable[8] = GetProcAddress(hWinspool, (LPSTR)215);
82
83 // Verify that all calls succeeded.
84 for (i = 0; i < 9; i++)
85 if (!pTable[i])
86 return FALSE;
87
88 return TRUE;
89 }
90
91 BOOL WINAPI
92 SplIsUpgrade()
93 {
94 return FALSE;
95 }
96
97 BOOL WINAPI
98 SpoolerInit()
99 {
100 // Nothing to do here yet
101 SetLastError(ERROR_SUCCESS);
102 return TRUE;
103 }