widl: Add support for protected attribute.
[wine.git] / dlls / spoolss / spoolss_main.c
blob355bf72b8229a9b94e3886e8e286ed70793eb4b8
1 /*
2 * Implementation of the Spooler-Service helper DLL
4 * Copyright 2006 Detlef Riekenberg
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winerror.h"
26 #include "winreg.h"
28 #include "wingdi.h"
29 #include "winspool.h"
30 #include "ddk/winsplp.h"
31 #include "spoolss.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(spoolss);
37 /* ################################ */
39 static HMODULE hwinspool;
41 /******************************************************************************
44 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
46 TRACE("(%p, %ld, %p)\n", hinstDLL, fdwReason, lpvReserved);
48 switch (fdwReason) {
49 case DLL_PROCESS_ATTACH: {
50 DisableThreadLibraryCalls(hinstDLL);
51 break;
53 case DLL_PROCESS_DETACH:
54 if (lpvReserved) break;
55 backend_unload_all();
56 break;
59 return TRUE;
62 /******************************************************************
63 * AllocSplStr [SPOOLSS.@]
65 * Create a copy from the String on the Spooler-Heap
67 * PARAMS
68 * pwstr [I] PTR to the String to copy
70 * RETURNS
71 * Failure: NULL
72 * Success: PTR to the copied String
75 LPWSTR WINAPI AllocSplStr(LPCWSTR pwstr)
77 LPWSTR res = NULL;
78 DWORD len;
80 TRACE("(%s)\n", debugstr_w(pwstr));
81 if (!pwstr) return NULL;
83 len = (lstrlenW(pwstr) + 1) * sizeof(WCHAR);
84 res = HeapAlloc(GetProcessHeap(), 0, len);
85 if (res) lstrcpyW(res, pwstr);
87 TRACE("returning %p\n", res);
88 return res;
91 /******************************************************************
92 * BuildOtherNamesFromMachineName [SPOOLSS.@]
94 BOOL WINAPI BuildOtherNamesFromMachineName(LPVOID * ptr1, LPVOID * ptr2)
96 FIXME("(%p, %p) stub\n", ptr1, ptr2);
98 *ptr1 = NULL;
99 *ptr2 = NULL;
100 return FALSE;
103 /******************************************************************
104 * DllAllocSplMem [SPOOLSS.@]
106 * Allocate cleared memory from the spooler heap
108 * PARAMS
109 * size [I] Number of bytes to allocate
111 * RETURNS
112 * Failure: NULL
113 * Success: PTR to the allocated memory
115 * NOTES
116 * We use the process heap (Windows use a separate spooler heap)
119 LPVOID WINAPI DllAllocSplMem(DWORD size)
121 LPVOID res;
123 res = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
124 TRACE("(%ld) => %p\n", size, res);
125 return res;
128 /******************************************************************
129 * DllFreeSplMem [SPOOLSS.@]
131 * Free the allocated spooler memory
133 * PARAMS
134 * memory [I] PTR to the memory allocated by DllAllocSplMem
136 * RETURNS
137 * Failure: FALSE
138 * Success: TRUE
140 * NOTES
141 * We use the process heap (Windows use a separate spooler heap)
145 BOOL WINAPI DllFreeSplMem(LPBYTE memory)
147 TRACE("(%p)\n", memory);
148 return HeapFree(GetProcessHeap(), 0, memory);
151 /******************************************************************
152 * DllFreeSplStr [SPOOLSS.@]
154 * Free the allocated Spooler-String
156 * PARAMS
157 * pwstr [I] PTR to the WSTR, allocated by AllocSplStr
159 * RETURNS
160 * Failure: FALSE
161 * Success: TRUE
165 BOOL WINAPI DllFreeSplStr(LPWSTR pwstr)
167 TRACE("(%s) PTR: %p\n", debugstr_w(pwstr), pwstr);
168 return HeapFree(GetProcessHeap(), 0, pwstr);
172 /******************************************************************
173 * ImpersonatePrinterClient [SPOOLSS.@]
175 BOOL WINAPI ImpersonatePrinterClient(HANDLE hToken)
177 FIXME("(%p) stub\n", hToken);
178 return TRUE;
181 /******************************************************************
182 * InitializeRouter [SPOOLSS.@]
184 BOOL WINAPI InitializeRouter(void)
186 TRACE("()\n");
187 return backend_load_all();
190 /******************************************************************
191 * IsLocalCall [SPOOLSS.@]
193 BOOL WINAPI IsLocalCall(void)
195 FIXME("() stub\n");
196 return TRUE;
199 /******************************************************************
200 * RevertToPrinterSelf [SPOOLSS.@]
202 HANDLE WINAPI RevertToPrinterSelf(void)
204 FIXME("() stub\n");
205 return (HANDLE) 0xdead0947;
208 /******************************************************************
209 * SplInitializeWinSpoolDrv [SPOOLSS.@]
211 * Dynamic load "winspool.drv" and fill an array with some function-pointer
213 * PARAMS
214 * table [I] array of function-pointer to fill
216 * RETURNS
217 * Success: TRUE
218 * Failure: FALSE
220 * NOTES
221 * Native "spoolss.dll" from w2k fill the table with 11 Function-Pointer.
222 * We implement the XP-Version (The table has only 9 Pointer)
225 BOOL WINAPI SplInitializeWinSpoolDrv(LPVOID * table)
227 DWORD res;
229 TRACE("(%p)\n", table);
231 hwinspool = LoadLibraryW(L"winspool.drv");
232 if (!hwinspool) return FALSE;
234 table[0] = (void *) GetProcAddress(hwinspool, "OpenPrinterW");
235 table[1] = (void *) GetProcAddress(hwinspool, "ClosePrinter");
236 table[2] = (void *) GetProcAddress(hwinspool, "SpoolerDevQueryPrintW");
237 table[3] = (void *) GetProcAddress(hwinspool, "SpoolerPrinterEvent");
238 table[4] = (void *) GetProcAddress(hwinspool, "DocumentPropertiesW");
239 table[5] = (void *) GetProcAddress(hwinspool, (LPSTR) 212); /* LoadPrinterDriver */
240 table[6] = (void *) GetProcAddress(hwinspool, (LPSTR) 213); /* RefCntLoadDriver */
241 table[7] = (void *) GetProcAddress(hwinspool, (LPSTR) 214); /* RefCntUnloadDriver */
242 table[8] = (void *) GetProcAddress(hwinspool, (LPSTR) 215); /* ForceUnloadDriver */
244 for (res = 0; res < 9; res++) {
245 if (table[res] == NULL) return FALSE;
248 return TRUE;
252 /******************************************************************
253 * SplIsUpgrade [SPOOLSS.@]
255 BOOL WINAPI SplIsUpgrade(void)
257 FIXME("() stub\n");
258 return FALSE;
261 /******************************************************************
262 * SpoolerHasInitialized [SPOOLSS.@]
264 BOOL WINAPI SpoolerHasInitialized(void)
266 FIXME("() stub\n");
267 return TRUE;
270 /******************************************************************
271 * SpoolerInit [SPOOLSS.@]
273 BOOL WINAPI SpoolerInit(void)
275 FIXME("() stub\n");
276 return TRUE;
279 /******************************************************************
280 * WaitForSpoolerInitialization [SPOOLSS.@]
282 BOOL WINAPI WaitForSpoolerInitialization(void)
284 FIXME("() stub\n");
285 return TRUE;