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>
11 _RpcClosePrinter(WINSPOOL_PRINTER_HANDLE
*phPrinter
)
15 dwErrorCode
= RpcImpersonateClient(NULL
);
16 if (dwErrorCode
!= ERROR_SUCCESS
)
18 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode
);
22 if (ClosePrinter(*phPrinter
))
25 dwErrorCode
= GetLastError();
32 _RpcEndDocPrinter(WINSPOOL_PRINTER_HANDLE hPrinter
)
36 dwErrorCode
= RpcImpersonateClient(NULL
);
37 if (dwErrorCode
!= ERROR_SUCCESS
)
39 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode
);
43 EndDocPrinter(hPrinter
);
44 dwErrorCode
= GetLastError();
51 _RpcEndPagePrinter(WINSPOOL_PRINTER_HANDLE hPrinter
)
55 dwErrorCode
= RpcImpersonateClient(NULL
);
56 if (dwErrorCode
!= ERROR_SUCCESS
)
58 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode
);
62 EndPagePrinter(hPrinter
);
63 dwErrorCode
= GetLastError();
70 _RpcEnumPrinters(DWORD Flags
, WINSPOOL_HANDLE Name
, DWORD Level
, BYTE
* pPrinterEnum
, DWORD cbBuf
, DWORD
* pcbNeeded
, DWORD
* pcReturned
)
74 dwErrorCode
= RpcImpersonateClient(NULL
);
75 if (dwErrorCode
!= ERROR_SUCCESS
)
77 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode
);
81 EnumPrintersW(Flags
, Name
, Level
, pPrinterEnum
, cbBuf
, pcbNeeded
, pcReturned
);
82 dwErrorCode
= GetLastError();
89 _RpcOpenPrinter(WINSPOOL_HANDLE pPrinterName
, WINSPOOL_PRINTER_HANDLE
* phPrinter
, WCHAR
* pDatatype
, WINSPOOL_DEVMODE_CONTAINER
* pDevModeContainer
, DWORD AccessRequired
)
92 PRINTER_DEFAULTSW Default
;
94 dwErrorCode
= RpcImpersonateClient(NULL
);
95 if (dwErrorCode
!= ERROR_SUCCESS
)
97 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode
);
101 Default
.DesiredAccess
= AccessRequired
;
102 Default
.pDatatype
= pDatatype
;
103 Default
.pDevMode
= (PDEVMODEW
)pDevModeContainer
->pDevMode
;
105 OpenPrinterW(pPrinterName
, phPrinter
, &Default
);
106 dwErrorCode
= GetLastError();
113 _RpcReadPrinter(WINSPOOL_PRINTER_HANDLE hPrinter
, BYTE
*pBuf
, DWORD cbBuf
, DWORD
*pcNoBytesRead
)
117 dwErrorCode
= RpcImpersonateClient(NULL
);
118 if (dwErrorCode
!= ERROR_SUCCESS
)
120 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode
);
124 ReadPrinter(hPrinter
, pBuf
, cbBuf
, pcNoBytesRead
);
125 dwErrorCode
= GetLastError();
132 _RpcStartDocPrinter(WINSPOOL_PRINTER_HANDLE hPrinter
, WINSPOOL_DOC_INFO_CONTAINER
* pDocInfoContainer
, DWORD
* pJobId
)
136 dwErrorCode
= RpcImpersonateClient(NULL
);
137 if (dwErrorCode
!= ERROR_SUCCESS
)
139 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode
);
143 *pJobId
= StartDocPrinterW(hPrinter
, pDocInfoContainer
->Level
, (PBYTE
)pDocInfoContainer
->DocInfo
.pDocInfo1
);
144 dwErrorCode
= GetLastError();
151 _RpcStartPagePrinter(WINSPOOL_PRINTER_HANDLE hPrinter
)
155 dwErrorCode
= RpcImpersonateClient(NULL
);
156 if (dwErrorCode
!= ERROR_SUCCESS
)
158 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode
);
162 StartPagePrinter(hPrinter
);
163 dwErrorCode
= GetLastError();
170 _RpcWritePrinter(WINSPOOL_PRINTER_HANDLE hPrinter
, BYTE
*pBuf
, DWORD cbBuf
, DWORD
*pcWritten
)
174 dwErrorCode
= RpcImpersonateClient(NULL
);
175 if (dwErrorCode
!= ERROR_SUCCESS
)
177 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode
);
181 WritePrinter(hPrinter
, pBuf
, cbBuf
, pcWritten
);
182 dwErrorCode
= GetLastError();