change default iSmCaptionWidth to 12
[wine/kumbayo.git] / dlls / spoolss / spoolss_main.c
blob2fee59ea2a9517d74910e469310d1cf3b566fd76
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 * BuildOtherNamesFromMachineName [SPOOLSS.@]
85 BOOL WINAPI BuildOtherNamesFromMachineName(LPVOID * ptr1, LPVOID * ptr2)
87 FIXME("(%p, %p) stub\n", ptr1, ptr2);
89 *ptr1 = NULL;
90 *ptr2 = NULL;
91 return FALSE;
94 /******************************************************************
95 * DllAllocSplMem [SPOOLSS.@]
97 * Allocate cleared memory from the spooler heap
99 * PARAMS
100 * size [I] Number of bytes to allocate
102 * RETURNS
103 * Failure: NULL
104 * Success: PTR to the allocated memory
106 * NOTES
107 * We use the process heap (Windows use a separate spooler heap)
110 LPVOID WINAPI DllAllocSplMem(DWORD size)
112 LPVOID res;
114 res = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
115 TRACE("(%d) => %p\n", size, res);
116 return res;
119 /******************************************************************
120 * DllFreeSplMem [SPOOLSS.@]
122 * Free the allocated spooler memory
124 * PARAMS
125 * memory [I] PTR to the memory allocated by DllAllocSplMem
127 * RETURNS
128 * Failure: FALSE
129 * Success: TRUE
131 * NOTES
132 * We use the process heap (Windows use a separate spooler heap)
136 BOOL WINAPI DllFreeSplMem(LPBYTE memory)
138 TRACE("(%p)\n", memory);
139 return HeapFree(GetProcessHeap(), 0, memory);
142 /******************************************************************
143 * DllFreeSplStr [SPOOLSS.@]
145 * Free the allocated Spooler-String
147 * PARAMS
148 * pwstr [I] PTR to the WSTR, allocated by AllocSplStr
150 * RETURNS
151 * Failure: FALSE
152 * Success: TRUE
156 BOOL WINAPI DllFreeSplStr(LPWSTR pwstr)
158 TRACE("(%s) PTR: %p\n", debugstr_w(pwstr), pwstr);
159 return HeapFree(GetProcessHeap(), 0, pwstr);
163 /******************************************************************
164 * ImpersonatePrinterClient [SPOOLSS.@]
166 BOOL WINAPI ImpersonatePrinterClient(HANDLE hToken)
168 FIXME("(%p) stub\n", hToken);
169 return TRUE;
172 /******************************************************************
173 * RevertToPrinterSelf [SPOOLSS.@]
175 HANDLE WINAPI RevertToPrinterSelf(void)
177 FIXME("() stub\n");
178 return (HANDLE) 0xdead0947;
181 /******************************************************************
182 * SplInitializeWinSpoolDrv [SPOOLSS.@]
184 * Dynamic load "winspool.drv" and fill an array with some function-pointer
186 * PARAMS
187 * table [I] array of function-pointer to fill
189 * RETURNS
190 * Success: TRUE
191 * Failure: FALSE
193 * NOTES
194 * Native "spoolss.dll" from w2k fill the table with 11 Function-Pointer.
195 * We implement the XP-Version (The table has only 9 Pointer)
198 BOOL WINAPI SplInitializeWinSpoolDrv(LPVOID * table)
200 DWORD res;
202 TRACE("(%p)\n", table);
204 hwinspool = LoadLibraryW(winspooldrvW);
205 if (!hwinspool) return FALSE;
207 table[0] = (void *) GetProcAddress(hwinspool, "OpenPrinterW");
208 table[1] = (void *) GetProcAddress(hwinspool, "ClosePrinter");
209 table[2] = (void *) GetProcAddress(hwinspool, "SpoolerDevQueryPrintW");
210 table[3] = (void *) GetProcAddress(hwinspool, "SpoolerPrinterEvent");
211 table[4] = (void *) GetProcAddress(hwinspool, "DocumentPropertiesW");
212 table[5] = (void *) GetProcAddress(hwinspool, (LPSTR) 212); /* LoadPrinterDriver */
213 table[6] = (void *) GetProcAddress(hwinspool, (LPSTR) 213); /* RefCntLoadDriver */
214 table[7] = (void *) GetProcAddress(hwinspool, (LPSTR) 214); /* RefCntUnloadDriver */
215 table[8] = (void *) GetProcAddress(hwinspool, (LPSTR) 215); /* ForceUnloadDriver */
217 for (res = 0; res < 9; res++) {
218 if (table[res] == NULL) return FALSE;
221 return TRUE;
225 /******************************************************************
226 * SplIsUpgrade [SPOOLSS.@]
228 BOOL WINAPI SplIsUpgrade(void)
230 FIXME("() stub\n");
231 return FALSE;