wined3d: Pass the pixel shader input signature to shader_arb_generate_vshader.
[wine.git] / dlls / winspool.drv / wspool.c
blob1f251298a70c4b176fbc6420c06bbe287f7549c2
1 /******************************************************************************
2 * Print Spooler Functions
5 * Copyright 1999 Thuy Nguyen
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "config.h"
24 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wingdi.h"
29 #include "winspool.h"
31 #include "winreg.h"
32 #include "ddk/winsplp.h"
33 #include "wine/debug.h"
35 #include "wspool.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(winspool);
39 /* ############################### */
41 static CRITICAL_SECTION backend_cs;
42 static CRITICAL_SECTION_DEBUG backend_cs_debug =
44 0, 0, &backend_cs,
45 { &backend_cs_debug.ProcessLocksList, &backend_cs_debug.ProcessLocksList },
46 0, 0, { (DWORD_PTR)(__FILE__ ": backend_cs") }
48 static CRITICAL_SECTION backend_cs = { &backend_cs_debug, -1, 0, 0, 0, 0 };
50 /* ############################### */
52 HINSTANCE WINSPOOL_hInstance = NULL;
54 static HMODULE hlocalspl = NULL;
55 static BOOL (WINAPI *pInitializePrintProvidor)(LPPRINTPROVIDOR, DWORD, LPWSTR);
57 PRINTPROVIDOR * backend = NULL;
59 /******************************************************************************
60 * load_backend [internal]
62 * load and init our backend (the local printprovider: "localspl.dll")
64 * PARAMS
66 * RETURNS
67 * Success: TRUE
68 * Failure: FALSE and RPC_S_SERVER_UNAVAILABLE
70 * NOTES
71 * In windows, winspool.drv use RPC to interact with the spooler service
72 * (spoolsv.exe with spoolss.dll) and the spooler router (spoolss.dll) interact
73 * with the correct printprovider (localspl.dll for the local system)
76 BOOL load_backend(void)
78 static PRINTPROVIDOR mybackend;
79 DWORD res;
81 EnterCriticalSection(&backend_cs);
82 hlocalspl = LoadLibraryA("localspl.dll");
83 if (hlocalspl) {
84 pInitializePrintProvidor = (void *) GetProcAddress(hlocalspl, "InitializePrintProvidor");
85 if (pInitializePrintProvidor) {
87 /* native localspl does not clear unused entries */
88 memset(&mybackend, 0, sizeof(mybackend));
89 res = pInitializePrintProvidor(&mybackend, sizeof(mybackend), NULL);
90 if (res) {
91 backend = &mybackend;
92 LeaveCriticalSection(&backend_cs);
93 TRACE("backend: %p (%p)\n", backend, hlocalspl);
94 return TRUE;
97 FreeLibrary(hlocalspl);
100 LeaveCriticalSection(&backend_cs);
102 WARN("failed to load the backend: %u\n", GetLastError());
103 SetLastError(RPC_S_SERVER_UNAVAILABLE);
104 return FALSE;
107 /******************************************************************************
108 * unload_backend [internal]
111 static void unload_backend(void)
113 EnterCriticalSection(&backend_cs);
114 backend = NULL;
115 FreeLibrary(hlocalspl);
116 LeaveCriticalSection(&backend_cs);
117 DeleteCriticalSection(&backend_cs);
121 /******************************************************************************
122 * DllMain
124 * Winspool entry point.
127 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD reason, LPVOID lpReserved)
129 switch (reason)
131 case DLL_PROCESS_ATTACH: {
132 WINSPOOL_hInstance = hInstance;
133 DisableThreadLibraryCalls(hInstance);
134 WINSPOOL_LoadSystemPrinters();
135 break;
137 case DLL_PROCESS_DETACH:
138 unload_backend();
139 break;
142 return TRUE;