include: Make sure __int64 is correctly defined on PPC64.
[wine.git] / dlls / spoolss / spoolss_main.c
blobbee58755eee052821159150d0d03a3759f6ad72a
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, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
48 switch (fdwReason) {
49 case DLL_WINE_PREATTACH:
50 return FALSE; /* prefer native version */
51 case DLL_PROCESS_ATTACH: {
52 DisableThreadLibraryCalls(hinstDLL);
53 break;
55 case DLL_PROCESS_DETACH:
56 if (lpvReserved) break;
57 backend_unload_all();
58 break;
61 return TRUE;
64 /******************************************************************
65 * AllocSplStr [SPOOLSS.@]
67 * Create a copy from the String on the Spooler-Heap
69 * PARAMS
70 * pwstr [I] PTR to the String to copy
72 * RETURNS
73 * Failure: NULL
74 * Success: PTR to the copied String
77 LPWSTR WINAPI AllocSplStr(LPCWSTR pwstr)
79 LPWSTR res = NULL;
80 DWORD len;
82 TRACE("(%s)\n", debugstr_w(pwstr));
83 if (!pwstr) return NULL;
85 len = (lstrlenW(pwstr) + 1) * sizeof(WCHAR);
86 res = HeapAlloc(GetProcessHeap(), 0, len);
87 if (res) lstrcpyW(res, pwstr);
89 TRACE("returning %p\n", res);
90 return res;
93 /******************************************************************
94 * BuildOtherNamesFromMachineName [SPOOLSS.@]
96 BOOL WINAPI BuildOtherNamesFromMachineName(LPVOID * ptr1, LPVOID * ptr2)
98 FIXME("(%p, %p) stub\n", ptr1, ptr2);
100 *ptr1 = NULL;
101 *ptr2 = NULL;
102 return FALSE;
105 /******************************************************************
106 * DllAllocSplMem [SPOOLSS.@]
108 * Allocate cleared memory from the spooler heap
110 * PARAMS
111 * size [I] Number of bytes to allocate
113 * RETURNS
114 * Failure: NULL
115 * Success: PTR to the allocated memory
117 * NOTES
118 * We use the process heap (Windows use a separate spooler heap)
121 LPVOID WINAPI DllAllocSplMem(DWORD size)
123 LPVOID res;
125 res = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
126 TRACE("(%d) => %p\n", size, res);
127 return res;
130 /******************************************************************
131 * DllFreeSplMem [SPOOLSS.@]
133 * Free the allocated spooler memory
135 * PARAMS
136 * memory [I] PTR to the memory allocated by DllAllocSplMem
138 * RETURNS
139 * Failure: FALSE
140 * Success: TRUE
142 * NOTES
143 * We use the process heap (Windows use a separate spooler heap)
147 BOOL WINAPI DllFreeSplMem(LPBYTE memory)
149 TRACE("(%p)\n", memory);
150 return HeapFree(GetProcessHeap(), 0, memory);
153 /******************************************************************
154 * DllFreeSplStr [SPOOLSS.@]
156 * Free the allocated Spooler-String
158 * PARAMS
159 * pwstr [I] PTR to the WSTR, allocated by AllocSplStr
161 * RETURNS
162 * Failure: FALSE
163 * Success: TRUE
167 BOOL WINAPI DllFreeSplStr(LPWSTR pwstr)
169 TRACE("(%s) PTR: %p\n", debugstr_w(pwstr), pwstr);
170 return HeapFree(GetProcessHeap(), 0, pwstr);
174 /******************************************************************
175 * ImpersonatePrinterClient [SPOOLSS.@]
177 BOOL WINAPI ImpersonatePrinterClient(HANDLE hToken)
179 FIXME("(%p) stub\n", hToken);
180 return TRUE;
183 /******************************************************************
184 * InitializeRouter [SPOOLSS.@]
186 BOOL WINAPI InitializeRouter(void)
188 TRACE("()\n");
189 return backend_load_all();
192 /******************************************************************
193 * IsLocalCall [SPOOLSS.@]
195 BOOL WINAPI IsLocalCall(void)
197 FIXME("() stub\n");
198 return TRUE;
201 /******************************************************************
202 * RevertToPrinterSelf [SPOOLSS.@]
204 HANDLE WINAPI RevertToPrinterSelf(void)
206 FIXME("() stub\n");
207 return (HANDLE) 0xdead0947;
210 /******************************************************************
211 * SplInitializeWinSpoolDrv [SPOOLSS.@]
213 * Dynamic load "winspool.drv" and fill an array with some function-pointer
215 * PARAMS
216 * table [I] array of function-pointer to fill
218 * RETURNS
219 * Success: TRUE
220 * Failure: FALSE
222 * NOTES
223 * Native "spoolss.dll" from w2k fill the table with 11 Function-Pointer.
224 * We implement the XP-Version (The table has only 9 Pointer)
227 BOOL WINAPI SplInitializeWinSpoolDrv(LPVOID * table)
229 DWORD res;
231 TRACE("(%p)\n", table);
233 hwinspool = LoadLibraryW(L"winspool.drv");
234 if (!hwinspool) return FALSE;
236 table[0] = (void *) GetProcAddress(hwinspool, "OpenPrinterW");
237 table[1] = (void *) GetProcAddress(hwinspool, "ClosePrinter");
238 table[2] = (void *) GetProcAddress(hwinspool, "SpoolerDevQueryPrintW");
239 table[3] = (void *) GetProcAddress(hwinspool, "SpoolerPrinterEvent");
240 table[4] = (void *) GetProcAddress(hwinspool, "DocumentPropertiesW");
241 table[5] = (void *) GetProcAddress(hwinspool, (LPSTR) 212); /* LoadPrinterDriver */
242 table[6] = (void *) GetProcAddress(hwinspool, (LPSTR) 213); /* RefCntLoadDriver */
243 table[7] = (void *) GetProcAddress(hwinspool, (LPSTR) 214); /* RefCntUnloadDriver */
244 table[8] = (void *) GetProcAddress(hwinspool, (LPSTR) 215); /* ForceUnloadDriver */
246 for (res = 0; res < 9; res++) {
247 if (table[res] == NULL) return FALSE;
250 return TRUE;
254 /******************************************************************
255 * SplIsUpgrade [SPOOLSS.@]
257 BOOL WINAPI SplIsUpgrade(void)
259 FIXME("() stub\n");
260 return FALSE;
263 /******************************************************************
264 * SpoolerHasInitialized [SPOOLSS.@]
266 BOOL WINAPI SpoolerHasInitialized(void)
268 FIXME("() stub\n");
269 return TRUE;
272 /******************************************************************
273 * SpoolerInit [SPOOLSS.@]
275 BOOL WINAPI SpoolerInit(void)
277 FIXME("() stub\n");
278 return TRUE;
281 /******************************************************************
282 * WaitForSpoolerInitialization [SPOOLSS.@]
284 BOOL WINAPI WaitForSpoolerInitialization(void)
286 FIXME("() stub\n");
287 return TRUE;