[WINSPOOL]
[reactos.git] / reactos / win32ss / printing / base / spoolsv / printers.c
1 /*
2 * PROJECT: ReactOS Print Spooler Service
3 * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation
4 * PURPOSE: Functions related to Printers and printing
5 * COPYRIGHT: Copyright 2015 Colin Finck <colin@reactos.org>
6 */
7
8 #include "precomp.h"
9
10 DWORD
11 _RpcEnumPrinters(DWORD Flags, WINSPOOL_HANDLE Name, DWORD Level, BYTE* pPrinterEnum, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned)
12 {
13 DWORD dwErrorCode;
14
15 dwErrorCode = RpcImpersonateClient(NULL);
16 if (dwErrorCode != ERROR_SUCCESS)
17 {
18 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
19 return dwErrorCode;
20 }
21
22 EnumPrintersW(Flags, Name, Level, pPrinterEnum, cbBuf, pcbNeeded, pcReturned);
23 dwErrorCode = GetLastError();
24
25 RpcRevertToSelf();
26 return dwErrorCode;
27 }
28
29 DWORD
30 _RpcOpenPrinter(WINSPOOL_HANDLE pPrinterName, WINSPOOL_PRINTER_HANDLE* phPrinter, WCHAR* pDatatype, WINSPOOL_DEVMODE_CONTAINER* pDevModeContainer, DWORD AccessRequired)
31 {
32 DWORD dwErrorCode;
33 PRINTER_DEFAULTSW Default;
34
35 dwErrorCode = RpcImpersonateClient(NULL);
36 if (dwErrorCode != ERROR_SUCCESS)
37 {
38 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
39 return dwErrorCode;
40 }
41
42 Default.DesiredAccess = AccessRequired;
43 Default.pDatatype = pDatatype;
44 Default.pDevMode = (PDEVMODEW)pDevModeContainer->pDevMode;
45
46 OpenPrinterW(pPrinterName, phPrinter, &Default);
47 dwErrorCode = GetLastError();
48
49 RpcRevertToSelf();
50 return dwErrorCode;
51 }