spoolss: Add a stub for SplIsUpgrade.
[wine/wine64.git] / dlls / spoolss / spoolss_main.c
blob9a9ec4893e6f08241a346ac1ab54030e7aefb12c
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 "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(spoolss);
30 /* ################################ */
32 static HMODULE hwinspool;
33 static const WCHAR winspooldrvW[] = {'w','i','n','s','p','o','o','l','.','d','r','v',0};
35 /******************************************************************
38 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
40 TRACE("(%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
42 switch (fdwReason) {
43 case DLL_WINE_PREATTACH:
44 return FALSE; /* prefer native version */
45 case DLL_PROCESS_ATTACH: {
46 DisableThreadLibraryCalls(hinstDLL);
47 break;
50 return TRUE;
53 /******************************************************************
54 * AllocSplStr [SPOOLSS.@]
56 * Create a copy from the String on the Spooler-Heap
58 * PARAMS
59 * pwstr [I] PTR to the String to copy
61 * RETURNS
62 * Failure: NULL
63 * Success: PTR to the copied String
66 LPWSTR WINAPI AllocSplStr(LPCWSTR pwstr)
68 LPWSTR res = NULL;
69 DWORD len;
71 TRACE("(%s)\n", debugstr_w(pwstr));
72 if (!pwstr) return NULL;
74 len = (lstrlenW(pwstr) + 1) * sizeof(WCHAR);
75 res = HeapAlloc(GetProcessHeap(), 0, len);
76 if (res) lstrcpyW(res, pwstr);
78 TRACE("returning %p\n", res);
79 return res;
82 /******************************************************************
83 * DllAllocSplMem [SPOOLSS.@]
85 * Allocate cleared memory from the spooler heap
87 * PARAMS
88 * size [I] Number of bytes to allocate
90 * RETURNS
91 * Failure: NULL
92 * Success: PTR to the allocated memory
94 * NOTES
95 * We use the process heap (Windows use a separate spooler heap)
98 LPVOID WINAPI DllAllocSplMem(DWORD size)
100 LPVOID res;
102 res = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
103 TRACE("(%d) => %p\n", size, res);
104 return res;
107 /******************************************************************
108 * DllFreeSplMem [SPOOLSS.@]
110 * Free the allocated spooler memory
112 * PARAMS
113 * memory [I] PTR to the memory allocated by DllAllocSplMem
115 * RETURNS
116 * Failure: FALSE
117 * Success: TRUE
119 * NOTES
120 * We use the process heap (Windows use a separate spooler heap)
124 BOOL WINAPI DllFreeSplMem(LPBYTE memory)
126 TRACE("(%p)\n", memory);
127 return HeapFree(GetProcessHeap(), 0, memory);
130 /******************************************************************
131 * DllFreeSplStr [SPOOLSS.@]
133 * Free the allocated Spooler-String
135 * PARAMS
136 * pwstr [I] PTR to the WSTR, allocated by AllocSplStr
138 * RETURNS
139 * Failure: FALSE
140 * Success: TRUE
144 BOOL WINAPI DllFreeSplStr(LPWSTR pwstr)
146 TRACE("(%s) PTR: %p\n", debugstr_w(pwstr), pwstr);
147 return HeapFree(GetProcessHeap(), 0, pwstr);
151 /******************************************************************
152 * ImpersonatePrinterClient [SPOOLSS.@]
154 BOOL WINAPI ImpersonatePrinterClient(HANDLE hToken)
156 FIXME("(%p) stub\n", hToken);
157 return TRUE;
160 /******************************************************************
161 * RevertToPrinterSelf [SPOOLSS.@]
163 HANDLE WINAPI RevertToPrinterSelf(void)
165 FIXME("() stub\n");
166 return NULL;
169 /******************************************************************
170 * SplInitializeWinSpoolDrv [SPOOLSS.@]
172 * Dynamic load "winspool.drv" and fill an array with some function-pointer
174 * PARAMS
175 * table [I] array of function-pointer to fill
177 * RETURNS
178 * Success: TRUE
179 * Failure: FALSE
181 * NOTES
182 * Native "spoolss.dll" from w2k fill the table with 11 Function-Pointer.
183 * We implement the XP-Version (The table has only 9 Pointer)
186 BOOL WINAPI SplInitializeWinSpoolDrv(LPVOID * table)
188 DWORD res;
190 TRACE("(%p)\n", table);
192 hwinspool = LoadLibraryW(winspooldrvW);
193 if (!hwinspool) return FALSE;
195 table[0] = (void *) GetProcAddress(hwinspool, "OpenPrinterW");
196 table[1] = (void *) GetProcAddress(hwinspool, "ClosePrinter");
197 table[2] = (void *) GetProcAddress(hwinspool, "SpoolerDevQueryPrintW");
198 table[3] = (void *) GetProcAddress(hwinspool, "SpoolerPrinterEvent");
199 table[4] = (void *) GetProcAddress(hwinspool, "DocumentPropertiesW");
200 table[5] = (void *) GetProcAddress(hwinspool, (LPSTR) 212); /* LoadPrinterDriver */
201 table[6] = (void *) GetProcAddress(hwinspool, (LPSTR) 213); /* RefCntLoadDriver */
202 table[7] = (void *) GetProcAddress(hwinspool, (LPSTR) 214); /* RefCntUnloadDriver */
203 table[8] = (void *) GetProcAddress(hwinspool, (LPSTR) 215); /* ForceUnloadDriver */
205 for (res = 0; res < 9; res++) {
206 if (table[res] == NULL) return FALSE;
209 return TRUE;
213 /******************************************************************
214 * SplIsUpgrade [SPOOLSS.@]
216 BOOL WINAPI SplIsUpgrade(void)
218 FIXME("() stub\n");
219 return FALSE;